Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntityDesign / Design / System / Data / EntityModel / Emitters / EntityTypeEmitter.cs / 1305376 / EntityTypeEmitter.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.CodeDom; using System.Data; using Som=System.Data.EntityModel.SchemaObjectModel; using System.Data.Metadata.Edm; namespace System.Data.EntityModel.Emitters { ////// Summary description for ItemTypeEmitter. /// internal sealed class EntityTypeEmitter : StructuredTypeEmitter { #region Public Methods ////// /// /// /// public EntityTypeEmitter(ClientApiGenerator generator, EntityType entity) : base(generator, entity) { } #endregion #region Protected Methods ////// /// /// protected override void EmitProperties(CodeTypeDeclaration typeDecl) { base.EmitProperties(typeDecl); foreach ( NavigationProperty navigationProperty in Item.GetDeclaredOnlyMembers() ) { NavigationPropertyEmitter navigationPropertyEmitter = new NavigationPropertyEmitter(Generator, navigationProperty, UsingStandardBaseClass); navigationPropertyEmitter.Emit(typeDecl); } } public override CodeTypeDeclarationCollection EmitApiClass() { CodeTypeDeclarationCollection typeDecls = base.EmitApiClass(); if ( Item.KeyMembers.Count > 0 && typeDecls.Count == 1 ) { // generate xml comments for the key properties CodeTypeDeclaration typeDecl = typeDecls[0]; typeDecl.Comments.Add( new CodeCommentStatement( " ", true ) ); foreach ( EdmMember keyProperty in Item.KeyMembers) { string name = keyProperty.Name; typeDecl.Comments.Add( new CodeCommentStatement( name, true ) ); } typeDecl.Comments.Add( new CodeCommentStatement( " ", true ) ); } return typeDecls; } ////// /// /// protected override void EmitTypeAttributes(CodeTypeDeclaration typeDecl) { Generator.AttributeEmitter.EmitTypeAttributes( this, typeDecl ); base.EmitTypeAttributes( typeDecl ); } ////// /// ///protected override CodeTypeReference GetBaseType() { CodeTypeReference baseType = base.GetBaseType(); if (baseType == null) { baseType = TypeReference.EntityTypeBaseClass; } return baseType; } protected override ReadOnlyMetadataCollection GetProperties() { return Item.Properties; } #endregion #region Public Properties #endregion #region Protected Properties #endregion #region Private Properties /// /// Gets the SchemaElement that this class is generating code for. /// ///public new EntityType Item { get { return base.Item as EntityType; } } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.CodeDom; using System.Data; using Som=System.Data.EntityModel.SchemaObjectModel; using System.Data.Metadata.Edm; namespace System.Data.EntityModel.Emitters { ////// Summary description for ItemTypeEmitter. /// internal sealed class EntityTypeEmitter : StructuredTypeEmitter { #region Public Methods ////// /// /// /// public EntityTypeEmitter(ClientApiGenerator generator, EntityType entity) : base(generator, entity) { } #endregion #region Protected Methods ////// /// /// protected override void EmitProperties(CodeTypeDeclaration typeDecl) { base.EmitProperties(typeDecl); foreach ( NavigationProperty navigationProperty in Item.GetDeclaredOnlyMembers() ) { NavigationPropertyEmitter navigationPropertyEmitter = new NavigationPropertyEmitter(Generator, navigationProperty, UsingStandardBaseClass); navigationPropertyEmitter.Emit(typeDecl); } } public override CodeTypeDeclarationCollection EmitApiClass() { CodeTypeDeclarationCollection typeDecls = base.EmitApiClass(); if ( Item.KeyMembers.Count > 0 && typeDecls.Count == 1 ) { // generate xml comments for the key properties CodeTypeDeclaration typeDecl = typeDecls[0]; typeDecl.Comments.Add( new CodeCommentStatement( " ", true ) ); foreach ( EdmMember keyProperty in Item.KeyMembers) { string name = keyProperty.Name; typeDecl.Comments.Add( new CodeCommentStatement( name, true ) ); } typeDecl.Comments.Add( new CodeCommentStatement( " ", true ) ); } return typeDecls; } ////// /// /// protected override void EmitTypeAttributes(CodeTypeDeclaration typeDecl) { Generator.AttributeEmitter.EmitTypeAttributes( this, typeDecl ); base.EmitTypeAttributes( typeDecl ); } ////// /// ///protected override CodeTypeReference GetBaseType() { CodeTypeReference baseType = base.GetBaseType(); if (baseType == null) { baseType = TypeReference.EntityTypeBaseClass; } return baseType; } protected override ReadOnlyMetadataCollection GetProperties() { return Item.Properties; } #endregion #region Public Properties #endregion #region Protected Properties #endregion #region Private Properties /// /// Gets the SchemaElement that this class is generating code for. /// ///public new EntityType Item { get { return base.Item as EntityType; } } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ProjectionPruner.cs
- DataSourceCollectionBase.cs
- WebPartEditorOkVerb.cs
- ReaderWriterLockWrapper.cs
- IPAddress.cs
- CompositeKey.cs
- VectorAnimationBase.cs
- EncoderFallback.cs
- Track.cs
- XslVisitor.cs
- PageThemeParser.cs
- SByteStorage.cs
- Tokenizer.cs
- _StreamFramer.cs
- IgnoreFileBuildProvider.cs
- UriParserTemplates.cs
- SafeCertificateContext.cs
- WebPartConnectionsCloseVerb.cs
- CategoryEditor.cs
- ConstructorArgumentAttribute.cs
- CodeAssignStatement.cs
- CompilerParameters.cs
- DataColumnCollection.cs
- COM2FontConverter.cs
- PrintingPermissionAttribute.cs
- ConfigurationStrings.cs
- ServiceTimeoutsElement.cs
- WeakReference.cs
- WebPartActionVerb.cs
- ToolTipAutomationPeer.cs
- MultiSelectRootGridEntry.cs
- InheritablePropertyChangeInfo.cs
- XmlIlVisitor.cs
- MdImport.cs
- CounterSample.cs
- ManualResetEvent.cs
- ThousandthOfEmRealDoubles.cs
- ButtonStandardAdapter.cs
- PageVisual.cs
- TablePattern.cs
- BookmarkInfo.cs
- HttpModuleAction.cs
- RTLAwareMessageBox.cs
- ForceCopyBuildProvider.cs
- SubMenuStyle.cs
- ChtmlTextWriter.cs
- SoundPlayerAction.cs
- AdRotatorDesigner.cs
- Region.cs
- CutCopyPasteHelper.cs
- HtmlInputReset.cs
- InlineObject.cs
- SmtpDigestAuthenticationModule.cs
- AdCreatedEventArgs.cs
- ContainerUtilities.cs
- HttpHeaderCollection.cs
- ApplicationInfo.cs
- BuildProviderCollection.cs
- NavigatorInput.cs
- ExpressionEditorSheet.cs
- BrowserCapabilitiesCodeGenerator.cs
- XhtmlBasicValidatorAdapter.cs
- ServerProtocol.cs
- KerberosSecurityTokenAuthenticator.cs
- HttpHandler.cs
- OleDbEnumerator.cs
- Frame.cs
- BaseTemplateParser.cs
- VectorCollection.cs
- Helpers.cs
- CustomErrorCollection.cs
- SetIndexBinder.cs
- StylusOverProperty.cs
- LexicalChunk.cs
- BaseConfigurationRecord.cs
- RequestResponse.cs
- ContentPlaceHolder.cs
- HScrollBar.cs
- EntityContainerRelationshipSetEnd.cs
- _HeaderInfo.cs
- SqlFileStream.cs
- XmlSchemaSimpleContent.cs
- FastEncoder.cs
- ToolStripCustomTypeDescriptor.cs
- KnownTypes.cs
- EventSinkHelperWriter.cs
- TypedDatasetGenerator.cs
- PrinterSettings.cs
- XmlObjectSerializerWriteContextComplex.cs
- TextEditorCopyPaste.cs
- _MultipleConnectAsync.cs
- StreamFormatter.cs
- GifBitmapDecoder.cs
- Types.cs
- ComponentRenameEvent.cs
- DataServiceEntityAttribute.cs
- OleDbSchemaGuid.cs
- DrawListViewColumnHeaderEventArgs.cs
- Timer.cs
- NumberFormatInfo.cs