Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Design / system / Data / EntityModel / Emitters / EntityTypeEmitter.cs / 1305376 / EntityTypeEmitter.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System.CodeDom; 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 (EdmMember member in Item.Members) { NavigationProperty navigationProperty = (member as NavigationProperty); if ((null != navigationProperty) && (navigationProperty.DeclaringType == Item)) { NavigationPropertyEmitter navigationPropertyEmitter = new NavigationPropertyEmitter(Generator, navigationProperty, UsingStandardBaseClass); navigationPropertyEmitter.Emit(typeDecl); } } } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "KeyProperties")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = ".ctor")] 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(); 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.CodeDom; 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 (EdmMember member in Item.Members) { NavigationProperty navigationProperty = (member as NavigationProperty); if ((null != navigationProperty) && (navigationProperty.DeclaringType == Item)) { NavigationPropertyEmitter navigationPropertyEmitter = new NavigationPropertyEmitter(Generator, navigationProperty, UsingStandardBaseClass); navigationPropertyEmitter.Emit(typeDecl); } } } [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "KeyProperties")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = ".ctor")] 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(); 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
- WindowAutomationPeer.cs
- PrimitiveDataContract.cs
- FormViewRow.cs
- MultilineStringConverter.cs
- ToolStripItemRenderEventArgs.cs
- QueryInterceptorAttribute.cs
- Policy.cs
- XPathArrayIterator.cs
- UnsafeNativeMethods.cs
- NonBatchDirectoryCompiler.cs
- ServiceHttpModule.cs
- PathSegment.cs
- SequentialUshortCollection.cs
- AnnotationService.cs
- PageClientProxyGenerator.cs
- SolidColorBrush.cs
- InstanceOwnerQueryResult.cs
- TaskFormBase.cs
- BevelBitmapEffect.cs
- FamilyTypefaceCollection.cs
- ResourceContainer.cs
- PackagePart.cs
- GridViewSortEventArgs.cs
- BoundField.cs
- Oid.cs
- MarginsConverter.cs
- MenuItemStyleCollectionEditor.cs
- DescriptionCreator.cs
- FormattedTextSymbols.cs
- TokenBasedSet.cs
- CapabilitiesRule.cs
- WebPartTransformer.cs
- HtmlContainerControl.cs
- PropertyChangedEventArgs.cs
- ImageListUtils.cs
- DesignTimeResourceProviderFactoryAttribute.cs
- StylusPointProperty.cs
- RootBrowserWindow.cs
- Evaluator.cs
- Vector3DAnimation.cs
- ExecutionEngineException.cs
- DbProviderSpecificTypePropertyAttribute.cs
- HuffCodec.cs
- RowBinding.cs
- RoutingExtensionElement.cs
- WindowsListViewSubItem.cs
- StringCollection.cs
- SchemaSetCompiler.cs
- ProgressBarHighlightConverter.cs
- XmlAttributeCollection.cs
- UriSectionReader.cs
- FontFamilyValueSerializer.cs
- WebPartZoneCollection.cs
- DateTimeValueSerializerContext.cs
- Stylesheet.cs
- WindowsProgressbar.cs
- ServiceNameElementCollection.cs
- ServiceReference.cs
- SafeNativeMethodsMilCoreApi.cs
- FacetValueContainer.cs
- basevalidator.cs
- InvalidMessageContractException.cs
- DeclarativeCatalogPart.cs
- FontResourceCache.cs
- TextElement.cs
- Int32AnimationUsingKeyFrames.cs
- BrowserCapabilitiesFactory.cs
- XmlSchemaRedefine.cs
- PhonemeEventArgs.cs
- GridViewDesigner.cs
- ValidatingReaderNodeData.cs
- SoapAttributes.cs
- BidPrivateBase.cs
- DataGridViewColumnStateChangedEventArgs.cs
- ResourceExpression.cs
- VarRemapper.cs
- TreeNodeBindingCollection.cs
- SafeNativeMethods.cs
- ChineseLunisolarCalendar.cs
- DateTimeUtil.cs
- RowToParametersTransformer.cs
- Convert.cs
- CellLabel.cs
- RoutingConfiguration.cs
- InvalidEnumArgumentException.cs
- PasswordRecovery.cs
- WebCategoryAttribute.cs
- ProgressiveCrcCalculatingStream.cs
- TypeForwardedToAttribute.cs
- DataView.cs
- AssemblyNameProxy.cs
- BrowserCapabilitiesCompiler.cs
- AppSettingsExpressionBuilder.cs
- Quaternion.cs
- HwndSubclass.cs
- TemplateControl.cs
- TypeContext.cs
- MethodCallConverter.cs
- AuthorizationSection.cs
- ProcessHostServerConfig.cs