Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Objects / DataClasses / RelationshipNavigation.cs / 1305376 / RelationshipNavigation.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Data.Common; using System.Globalization; using System.Text; using System.Data.Metadata.Edm; namespace System.Data.Objects.DataClasses { ////// This class describes a relationship navigation from the /// navigation property on one entity to another entity. It is /// used throughout the collections and refs system to describe a /// relationship and to connect from the navigation property on /// one end of a relationship to the navigation property on the /// other end. /// [Serializable] internal class RelationshipNavigation { // ------------ // Constructors // ------------ ////// Creates a navigation object with the given relationship /// name, role name for the source and role name for the /// destination. /// /// Canonical-space name of the relationship. /// Name of the role which is the source of the navigation. /// Name of the role which is the destination of the navigation. /// The navigation property which is the source of the navigation. /// The navigation property which is the destination of the navigation. internal RelationshipNavigation(string relationshipName, string from, string to, NavigationPropertyAccessor fromAccessor, NavigationPropertyAccessor toAccessor) { EntityUtil.CheckStringArgument(relationshipName, "relationshipName"); EntityUtil.CheckStringArgument(from, "from"); EntityUtil.CheckStringArgument(to, "to"); _relationshipName = relationshipName; _from = from; _to = to; _fromAccessor = fromAccessor; _toAccessor = toAccessor; } // ------ // Fields // ------ // The following fields are serialized. Adding or removing a serialized field is considered // a breaking change. This includes changing the field type or field name of existing // serialized fields. If you need to make this kind of change, it may be possible, but it // will require some custom serialization/deserialization code. private readonly string _relationshipName; private readonly string _from; private readonly string _to; [NonSerialized] private RelationshipNavigation _reverse; [NonSerialized] private NavigationPropertyAccessor _fromAccessor; [NonSerialized] private NavigationPropertyAccessor _toAccessor; // ---------- // Properties // ---------- ////// Canonical-space relationship name. /// internal string RelationshipName { get { return _relationshipName; } } ////// Role name for the source of this navigation. /// internal string From { get { return _from; } } ////// Role name for the destination of this navigation. /// internal string To { get { return _to; } } ////// Navigation property name for the destination of this navigation. /// NOTE: There is not a FromPropertyAccessor property on RelationshipNavigation because it is not currently accessed anywhere /// It is only used to calculate the "reverse" RelationshipNavigation. /// internal NavigationPropertyAccessor ToPropertyAccessor { get { return _toAccessor; } } internal bool IsInitialized { get { return _toAccessor != null && _fromAccessor != null; } } internal void InitializeAccessors(NavigationPropertyAccessor fromAccessor, NavigationPropertyAccessor toAccessor) { _fromAccessor = fromAccessor; _toAccessor = toAccessor; } ////// The "reverse" version of this navigation. /// internal RelationshipNavigation Reverse { get { if (_reverse == null || !_reverse.IsInitialized) { // the reverse relationship is exactly like this // one but from & to are switched _reverse = new RelationshipNavigation(_relationshipName, _to, _from, _toAccessor, _fromAccessor); } return _reverse; } } ////// Compares this instance to a given Navigation by their values. /// public override bool Equals(object obj) { RelationshipNavigation compareTo = obj as RelationshipNavigation; return ((this == compareTo) || ((null != this) && (null != compareTo) && (this.RelationshipName == compareTo.RelationshipName) && (this.From == compareTo.From) && (this.To == compareTo.To))); } ////// Returns a value-based hash code. /// ///the hash value of this Navigation public override int GetHashCode() { return this.RelationshipName.GetHashCode(); } // ------- // Methods // ------- ////// ToString is provided to simplify debugging, etc. /// public override string ToString() { return String.Format(CultureInfo.InvariantCulture, "RelationshipNavigation: ({0},{1},{2})", _relationshipName, _from, _to); } } } // 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.Data.Common; using System.Globalization; using System.Text; using System.Data.Metadata.Edm; namespace System.Data.Objects.DataClasses { ////// This class describes a relationship navigation from the /// navigation property on one entity to another entity. It is /// used throughout the collections and refs system to describe a /// relationship and to connect from the navigation property on /// one end of a relationship to the navigation property on the /// other end. /// [Serializable] internal class RelationshipNavigation { // ------------ // Constructors // ------------ ////// Creates a navigation object with the given relationship /// name, role name for the source and role name for the /// destination. /// /// Canonical-space name of the relationship. /// Name of the role which is the source of the navigation. /// Name of the role which is the destination of the navigation. /// The navigation property which is the source of the navigation. /// The navigation property which is the destination of the navigation. internal RelationshipNavigation(string relationshipName, string from, string to, NavigationPropertyAccessor fromAccessor, NavigationPropertyAccessor toAccessor) { EntityUtil.CheckStringArgument(relationshipName, "relationshipName"); EntityUtil.CheckStringArgument(from, "from"); EntityUtil.CheckStringArgument(to, "to"); _relationshipName = relationshipName; _from = from; _to = to; _fromAccessor = fromAccessor; _toAccessor = toAccessor; } // ------ // Fields // ------ // The following fields are serialized. Adding or removing a serialized field is considered // a breaking change. This includes changing the field type or field name of existing // serialized fields. If you need to make this kind of change, it may be possible, but it // will require some custom serialization/deserialization code. private readonly string _relationshipName; private readonly string _from; private readonly string _to; [NonSerialized] private RelationshipNavigation _reverse; [NonSerialized] private NavigationPropertyAccessor _fromAccessor; [NonSerialized] private NavigationPropertyAccessor _toAccessor; // ---------- // Properties // ---------- ////// Canonical-space relationship name. /// internal string RelationshipName { get { return _relationshipName; } } ////// Role name for the source of this navigation. /// internal string From { get { return _from; } } ////// Role name for the destination of this navigation. /// internal string To { get { return _to; } } ////// Navigation property name for the destination of this navigation. /// NOTE: There is not a FromPropertyAccessor property on RelationshipNavigation because it is not currently accessed anywhere /// It is only used to calculate the "reverse" RelationshipNavigation. /// internal NavigationPropertyAccessor ToPropertyAccessor { get { return _toAccessor; } } internal bool IsInitialized { get { return _toAccessor != null && _fromAccessor != null; } } internal void InitializeAccessors(NavigationPropertyAccessor fromAccessor, NavigationPropertyAccessor toAccessor) { _fromAccessor = fromAccessor; _toAccessor = toAccessor; } ////// The "reverse" version of this navigation. /// internal RelationshipNavigation Reverse { get { if (_reverse == null || !_reverse.IsInitialized) { // the reverse relationship is exactly like this // one but from & to are switched _reverse = new RelationshipNavigation(_relationshipName, _to, _from, _toAccessor, _fromAccessor); } return _reverse; } } ////// Compares this instance to a given Navigation by their values. /// public override bool Equals(object obj) { RelationshipNavigation compareTo = obj as RelationshipNavigation; return ((this == compareTo) || ((null != this) && (null != compareTo) && (this.RelationshipName == compareTo.RelationshipName) && (this.From == compareTo.From) && (this.To == compareTo.To))); } ////// Returns a value-based hash code. /// ///the hash value of this Navigation public override int GetHashCode() { return this.RelationshipName.GetHashCode(); } // ------- // Methods // ------- ////// ToString is provided to simplify debugging, etc. /// public override string ToString() { return String.Format(CultureInfo.InvariantCulture, "RelationshipNavigation: ({0},{1},{2})", _relationshipName, _from, _to); } } } // 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
- TextTabProperties.cs
- ReferenceConverter.cs
- RequestNavigateEventArgs.cs
- DataListItemCollection.cs
- Query.cs
- Rijndael.cs
- UDPClient.cs
- VectorCollectionConverter.cs
- SystemInfo.cs
- ScriptResourceAttribute.cs
- UIntPtr.cs
- ComPlusAuthorization.cs
- CompoundFileStreamReference.cs
- BlockCollection.cs
- ToolboxComponentsCreatedEventArgs.cs
- PagedDataSource.cs
- AlternateView.cs
- WmlSelectionListAdapter.cs
- AnnotationResourceChangedEventArgs.cs
- PeerContact.cs
- _FtpControlStream.cs
- Triplet.cs
- TransformedBitmap.cs
- WebServiceResponseDesigner.cs
- PrintPreviewGraphics.cs
- ProcessHost.cs
- SqlUtil.cs
- MobileDeviceCapabilitiesSectionHandler.cs
- EntityDataSourceColumn.cs
- MergeLocalizationDirectives.cs
- DefaultCommandExtensionCallback.cs
- EventSinkHelperWriter.cs
- DecimalAnimationUsingKeyFrames.cs
- DetailsViewUpdateEventArgs.cs
- WebConfigurationManager.cs
- Registration.cs
- FreezableCollection.cs
- Message.cs
- AspNetCompatibilityRequirementsAttribute.cs
- Pkcs9Attribute.cs
- EntityDataSourceDataSelection.cs
- WeakReference.cs
- GPStream.cs
- ActivationService.cs
- TypeDescriptor.cs
- CryptographicAttribute.cs
- EllipseGeometry.cs
- SHA1.cs
- TokenBasedSet.cs
- ScalarRestriction.cs
- DetailsViewRowCollection.cs
- XmlSchemaCompilationSettings.cs
- OperationResponse.cs
- ConfigurationPropertyAttribute.cs
- TryCatch.cs
- IgnoreSectionHandler.cs
- GeneralTransform3D.cs
- Roles.cs
- CornerRadius.cs
- TableParagraph.cs
- DeclarativeExpressionConditionDeclaration.cs
- SecondaryIndexList.cs
- TraversalRequest.cs
- InertiaExpansionBehavior.cs
- ArrayListCollectionBase.cs
- TypeUtil.cs
- VideoDrawing.cs
- UserInitiatedNavigationPermission.cs
- XmlNavigatorStack.cs
- MeshGeometry3D.cs
- ObjectDataSourceView.cs
- ThreadPool.cs
- ExpressionConverter.cs
- ConfigurationException.cs
- Quaternion.cs
- GlyphShapingProperties.cs
- MouseActionValueSerializer.cs
- NavigationProperty.cs
- ListViewGroupItemCollection.cs
- CanonicalizationDriver.cs
- XmlSchemaSequence.cs
- Component.cs
- XmlKeywords.cs
- TCPListener.cs
- ProtocolsConfigurationHandler.cs
- MissingMethodException.cs
- IxmlLineInfo.cs
- CallSiteOps.cs
- ProfessionalColorTable.cs
- FederatedMessageSecurityOverHttpElement.cs
- Polygon.cs
- MD5CryptoServiceProvider.cs
- ResourceReferenceExpression.cs
- AsyncPostBackErrorEventArgs.cs
- RepeatInfo.cs
- RelationshipNavigation.cs
- WindowsFormsEditorServiceHelper.cs
- Schedule.cs
- TextRangeSerialization.cs
- Figure.cs