Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / ndp / fx / src / DataEntity / System / Data / EntityModel / SchemaObjectModel / EntityContainerAssociationSet.cs / 1 / EntityContainerAssociationSet.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.Xml; using System.Data; using System.Data.Objects.DataClasses; using System.Data.Metadata.Edm; namespace System.Data.EntityModel.SchemaObjectModel { ////// Represents an AssociationSet element. /// internal sealed class EntityContainerAssociationSet : EntityContainerRelationshipSet { // Note: If you add more fields, please make sure you handle that in the clone method private Dictionary_relationshipEnds = new Dictionary (); private List _rolelessEnds = new List (); /// /// Constructs an EntityContainerAssociationSet /// /// Reference to the schema element. public EntityContainerAssociationSet( EntityContainer parentElement ) : base( parentElement ) { } ////// The ends defined and infered for this AssociationSet /// internal override IEnumerableEnds { get { foreach ( EntityContainerAssociationSetEnd end in _relationshipEnds.Values ) { yield return end; } foreach ( EntityContainerAssociationSetEnd end in _rolelessEnds ) { yield return end; } } } protected override bool HandleAttribute(XmlReader reader) { if (base.HandleAttribute(reader)) { return true; } else if (CanHandleAttribute(reader, XmlConstants.Association)) { HandleRelationshipTypeNameAttribute(reader); return true; } return false; } protected override bool HandleElement(XmlReader reader) { if (base.HandleElement(reader)) { return true; } else if (CanHandleElement(reader, XmlConstants.End)) { HandleEndElement(reader); return true; } return false; } /// /// The method that is called when an End element is encountered. /// /// The XmlReader positioned at the EndElement. private void HandleEndElement( XmlReader reader ) { Debug.Assert( reader != null ); EntityContainerAssociationSetEnd end = new EntityContainerAssociationSetEnd( this ); end.Parse( reader ); if ( end.Role == null ) { // we will resolve the role name later and put it in the // normal _relationshipEnds dictionary _rolelessEnds.Add( end ); return; } if ( HasEnd( end.Role ) ) { end.AddError( ErrorCode.InvalidName, EdmSchemaErrorSeverity.Error, reader, System.Data.Entity.Strings.DuplicateEndName(end.Name ) ); return; } _relationshipEnds.Add( end.Role, end ); } internal override void ResolveTopLevelNames() { base.ResolveTopLevelNames(); // this just got resolved if ( Relationship != null && Relationship.RelationshipKind != RelationshipKind.Association ) { AddError( ErrorCode.BadType, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.AssociationSetInvalidRelationshipKind(FQName ) ); } } internal override void ResolveSecondLevelNames() { base.ResolveSecondLevelNames(); // the base class should have fixed up the role names on my ends foreach (EntityContainerAssociationSetEnd end in _rolelessEnds) { if (end.Role != null) { if (HasEnd(end.Role)) { end.AddError(ErrorCode.InvalidName, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InferRelationshipEndGivesAlreadyDefinedEnd(end.EntitySet.FQName, Name)); } else { _relationshipEnds.Add(end.Role, end); } } // any that didn't get resolved will already have errors entered } _rolelessEnds.Clear(); } ////// Create and add a EntityContainerEnd from the IRelationshipEnd provided /// /// The relationship end of the end to add. /// The entitySet to associate with the relationship end. protected override void AddEnd( IRelationshipEnd relationshipEnd, EntityContainerEntitySet entitySet ) { Debug.Assert( relationshipEnd != null ); Debug.Assert( !_relationshipEnds.ContainsKey( relationshipEnd.Name ) ); // we expect set to be null sometimes EntityContainerAssociationSetEnd end = new EntityContainerAssociationSetEnd( this ); end.Role = relationshipEnd.Name; end.RelationshipEnd = relationshipEnd; end.EntitySet = entitySet; if ( end.EntitySet != null ) { _relationshipEnds.Add( end.Role, end ); } } protected override bool HasEnd( string role ) { return _relationshipEnds.ContainsKey( role ); } internal override SchemaElement Clone(SchemaElement parentElement) { EntityContainerAssociationSet associationSet = new EntityContainerAssociationSet((EntityContainer)parentElement); associationSet.Name = this.Name; associationSet.Relationship = this.Relationship; foreach (EntityContainerAssociationSetEnd end in this.Ends) { EntityContainerAssociationSetEnd clonedEnd = (EntityContainerAssociationSetEnd)end.Clone(associationSet); associationSet._relationshipEnds.Add(clonedEnd.Role, clonedEnd); } return associationSet; } } } // 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; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.Xml; using System.Data; using System.Data.Objects.DataClasses; using System.Data.Metadata.Edm; namespace System.Data.EntityModel.SchemaObjectModel { ////// Represents an AssociationSet element. /// internal sealed class EntityContainerAssociationSet : EntityContainerRelationshipSet { // Note: If you add more fields, please make sure you handle that in the clone method private Dictionary_relationshipEnds = new Dictionary (); private List _rolelessEnds = new List (); /// /// Constructs an EntityContainerAssociationSet /// /// Reference to the schema element. public EntityContainerAssociationSet( EntityContainer parentElement ) : base( parentElement ) { } ////// The ends defined and infered for this AssociationSet /// internal override IEnumerableEnds { get { foreach ( EntityContainerAssociationSetEnd end in _relationshipEnds.Values ) { yield return end; } foreach ( EntityContainerAssociationSetEnd end in _rolelessEnds ) { yield return end; } } } protected override bool HandleAttribute(XmlReader reader) { if (base.HandleAttribute(reader)) { return true; } else if (CanHandleAttribute(reader, XmlConstants.Association)) { HandleRelationshipTypeNameAttribute(reader); return true; } return false; } protected override bool HandleElement(XmlReader reader) { if (base.HandleElement(reader)) { return true; } else if (CanHandleElement(reader, XmlConstants.End)) { HandleEndElement(reader); return true; } return false; } /// /// The method that is called when an End element is encountered. /// /// The XmlReader positioned at the EndElement. private void HandleEndElement( XmlReader reader ) { Debug.Assert( reader != null ); EntityContainerAssociationSetEnd end = new EntityContainerAssociationSetEnd( this ); end.Parse( reader ); if ( end.Role == null ) { // we will resolve the role name later and put it in the // normal _relationshipEnds dictionary _rolelessEnds.Add( end ); return; } if ( HasEnd( end.Role ) ) { end.AddError( ErrorCode.InvalidName, EdmSchemaErrorSeverity.Error, reader, System.Data.Entity.Strings.DuplicateEndName(end.Name ) ); return; } _relationshipEnds.Add( end.Role, end ); } internal override void ResolveTopLevelNames() { base.ResolveTopLevelNames(); // this just got resolved if ( Relationship != null && Relationship.RelationshipKind != RelationshipKind.Association ) { AddError( ErrorCode.BadType, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.AssociationSetInvalidRelationshipKind(FQName ) ); } } internal override void ResolveSecondLevelNames() { base.ResolveSecondLevelNames(); // the base class should have fixed up the role names on my ends foreach (EntityContainerAssociationSetEnd end in _rolelessEnds) { if (end.Role != null) { if (HasEnd(end.Role)) { end.AddError(ErrorCode.InvalidName, EdmSchemaErrorSeverity.Error, System.Data.Entity.Strings.InferRelationshipEndGivesAlreadyDefinedEnd(end.EntitySet.FQName, Name)); } else { _relationshipEnds.Add(end.Role, end); } } // any that didn't get resolved will already have errors entered } _rolelessEnds.Clear(); } ////// Create and add a EntityContainerEnd from the IRelationshipEnd provided /// /// The relationship end of the end to add. /// The entitySet to associate with the relationship end. protected override void AddEnd( IRelationshipEnd relationshipEnd, EntityContainerEntitySet entitySet ) { Debug.Assert( relationshipEnd != null ); Debug.Assert( !_relationshipEnds.ContainsKey( relationshipEnd.Name ) ); // we expect set to be null sometimes EntityContainerAssociationSetEnd end = new EntityContainerAssociationSetEnd( this ); end.Role = relationshipEnd.Name; end.RelationshipEnd = relationshipEnd; end.EntitySet = entitySet; if ( end.EntitySet != null ) { _relationshipEnds.Add( end.Role, end ); } } protected override bool HasEnd( string role ) { return _relationshipEnds.ContainsKey( role ); } internal override SchemaElement Clone(SchemaElement parentElement) { EntityContainerAssociationSet associationSet = new EntityContainerAssociationSet((EntityContainer)parentElement); associationSet.Name = this.Name; associationSet.Relationship = this.Relationship; foreach (EntityContainerAssociationSetEnd end in this.Ends) { EntityContainerAssociationSetEnd clonedEnd = (EntityContainerAssociationSetEnd)end.Clone(associationSet); associationSet._relationshipEnds.Add(clonedEnd.Role, clonedEnd); } return associationSet; } } } // 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
- CollectionChangeEventArgs.cs
- ObjectStorage.cs
- MarshalByValueComponent.cs
- Bezier.cs
- COM2IPerPropertyBrowsingHandler.cs
- EncryptedKeyHashIdentifierClause.cs
- MenuItemAutomationPeer.cs
- WinInetCache.cs
- AppDomainShutdownMonitor.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- Merger.cs
- ConnectionProviderAttribute.cs
- CollectionContainer.cs
- XmlExpressionDumper.cs
- SingleTagSectionHandler.cs
- ObjectManager.cs
- ProfilePropertySettings.cs
- assertwrapper.cs
- TextRange.cs
- ContextMenu.cs
- ResolveMatchesMessageCD1.cs
- JavaScriptObjectDeserializer.cs
- GeometryModel3D.cs
- BrowserCapabilitiesCompiler.cs
- SpeechSeg.cs
- ServiceMoniker.cs
- EntryIndex.cs
- WebPartVerbsEventArgs.cs
- DomainUpDown.cs
- ModifierKeysConverter.cs
- Config.cs
- StringCollection.cs
- ObjectConverter.cs
- Highlights.cs
- JoinElimination.cs
- CommandConverter.cs
- HierarchicalDataBoundControlAdapter.cs
- FileDialogPermission.cs
- activationcontext.cs
- MetadataHelper.cs
- messageonlyhwndwrapper.cs
- EventItfInfo.cs
- WeakEventTable.cs
- EntityDataSourceDataSelectionPanel.cs
- ParentQuery.cs
- Visual.cs
- SettingsPropertyCollection.cs
- CommonXSendMessage.cs
- KeyboardNavigation.cs
- ApplicationTrust.cs
- X509Chain.cs
- ElementsClipboardData.cs
- CollectionTypeElement.cs
- FileDetails.cs
- ListDictionaryInternal.cs
- SystemKeyConverter.cs
- SettingsPropertyValueCollection.cs
- PerformanceCounterPermissionAttribute.cs
- SettingsBase.cs
- WindowsPen.cs
- HttpModuleCollection.cs
- ShapeTypeface.cs
- StaticSiteMapProvider.cs
- OutArgumentConverter.cs
- UnknownMessageReceivedEventArgs.cs
- ObjectStateEntryOriginalDbUpdatableDataRecord.cs
- GridViewColumnCollection.cs
- QuaternionRotation3D.cs
- ScopelessEnumAttribute.cs
- FormDesigner.cs
- DocumentNUp.cs
- ShadowGlyph.cs
- InternalSafeNativeMethods.cs
- InputLangChangeRequestEvent.cs
- WebPartZoneCollection.cs
- FontUnitConverter.cs
- DateTimeFormatInfoScanner.cs
- NameValueConfigurationElement.cs
- ResourcesChangeInfo.cs
- ConstructorExpr.cs
- iisPickupDirectory.cs
- DataSourceXmlSerializationAttribute.cs
- SimpleBitVector32.cs
- FilterElement.cs
- ToolbarAUtomationPeer.cs
- DynamicMethod.cs
- UseAttributeSetsAction.cs
- UnsafeNativeMethodsCLR.cs
- BufferBuilder.cs
- DataViewManager.cs
- SQLGuidStorage.cs
- DesignerDataColumn.cs
- FixedPosition.cs
- TrackBarRenderer.cs
- InvalidChannelBindingException.cs
- ProbeMatchesApril2005.cs
- FontConverter.cs
- CodeMemberField.cs
- ServiceObjectContainer.cs
- FloatUtil.cs