Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / EntityModel / SchemaObjectModel / EntityContainerAssociationSet.cs / 1305376 / 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; using System.Globalization; 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 Debug.Assert( Relationship == null || Relationship.RelationshipKind == RelationshipKind.Association, string.Format("The relationship referenced by the Association attribute of {0} is not an Association relationship.", 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
- DesignerProperties.cs
- EntityDesignPluralizationHandler.cs
- MemoryStream.cs
- ChannelSinkStacks.cs
- HtmlInputCheckBox.cs
- WorkerRequest.cs
- DataSourceDescriptorCollection.cs
- Rule.cs
- VariableElement.cs
- TypeConverterMarkupExtension.cs
- TemplateBindingExtension.cs
- FrameworkContentElement.cs
- SafeReversePInvokeHandle.cs
- NameValueConfigurationCollection.cs
- serverconfig.cs
- GlobalizationSection.cs
- InkCollectionBehavior.cs
- DetailsViewModeEventArgs.cs
- AppearanceEditorPart.cs
- Mouse.cs
- InternalPermissions.cs
- DependencyPropertyConverter.cs
- SQLInt32Storage.cs
- ManipulationDeltaEventArgs.cs
- DocumentEventArgs.cs
- Point.cs
- DoubleCollection.cs
- SingleAnimationBase.cs
- JavaScriptSerializer.cs
- PrinterUnitConvert.cs
- SQLBytes.cs
- StateMachineWorkflow.cs
- PageTheme.cs
- GridViewRowPresenter.cs
- ListViewGroupConverter.cs
- FigureParaClient.cs
- ToolStripDropDownClosedEventArgs.cs
- ReservationNotFoundException.cs
- ReadOnlyTernaryTree.cs
- StorageSetMapping.cs
- Scripts.cs
- ProcessingInstructionAction.cs
- Literal.cs
- Win32PrintDialog.cs
- ConnectionString.cs
- PackageRelationship.cs
- GACMembershipCondition.cs
- StorageMappingItemCollection.cs
- SymbolEqualComparer.cs
- TemplateParser.cs
- ObjectStorage.cs
- CodeDirectiveCollection.cs
- DataGridDefaultColumnWidthTypeConverter.cs
- Bitmap.cs
- SequentialUshortCollection.cs
- NetWebProxyFinder.cs
- ParserContext.cs
- RequestCachingSection.cs
- MSHTMLHostUtil.cs
- SmtpFailedRecipientException.cs
- AssemblyCache.cs
- _NativeSSPI.cs
- XmlMemberMapping.cs
- TimeSpanStorage.cs
- CustomValidator.cs
- PathGradientBrush.cs
- DictionaryBase.cs
- regiisutil.cs
- WebPartExportVerb.cs
- TextFormatterContext.cs
- CopyOfAction.cs
- remotingproxy.cs
- PersianCalendar.cs
- PerformanceCounterPermission.cs
- _HeaderInfo.cs
- TranslateTransform3D.cs
- WebPartAddingEventArgs.cs
- TabRenderer.cs
- GregorianCalendarHelper.cs
- ApplicationException.cs
- Graph.cs
- InlinedAggregationOperator.cs
- SpotLight.cs
- HttpTransportSecurity.cs
- Thickness.cs
- DummyDataSource.cs
- BamlLocalizableResource.cs
- DataGridViewRow.cs
- ObjectAssociationEndMapping.cs
- RouteParametersHelper.cs
- ControlsConfig.cs
- ConnectionPoolRegistry.cs
- NumberFormatInfo.cs
- GridItemPattern.cs
- FileSystemWatcher.cs
- ToolStripPanelCell.cs
- PackageRelationshipCollection.cs
- ParseNumbers.cs
- BamlRecordReader.cs
- SHA384CryptoServiceProvider.cs