Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataEntity / System / Data / Metadata / Edm / AssociationType.cs / 2 / AssociationType.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Data.Common; using System.Text; using System.Threading; using System.Diagnostics; namespace System.Data.Metadata.Edm { ////// Represents the Edm Association Type /// public sealed class AssociationType : RelationshipType { #region Constructors ////// Initializes a new instance of Association Type with the given name, namespace, version and ends /// /// name of the association type /// namespace of the association type /// version of the association type /// dataSpace in which this AssociationType belongs to ///Thrown if either the name, namespace or version attributes are null internal AssociationType(string name, string namespaceName, DataSpace dataSpace) : base(name, namespaceName, dataSpace) { _referentialConstraints = new ReadOnlyMetadataCollection(new MetadataCollection ()); } #endregion #region Fields private readonly ReadOnlyMetadataCollection _referentialConstraints; private FilteredReadOnlyMetadataCollection _associationEndMembers; #endregion #region Properties /// /// Returns the kind of the type /// public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.AssociationType; } } ////// Returns the list of ends for this association type /// public ReadOnlyMetadataCollectionAssociationEndMembers { get { Debug.Assert(IsReadOnly, "this is a wrapper around this.Members, don't call it during metadata loading, only call it after the metadata is set to readonly"); if (null == _associationEndMembers) { Interlocked.CompareExchange(ref _associationEndMembers, new FilteredReadOnlyMetadataCollection ( this.Members, Helper.IsAssociationEndMember), null); } return _associationEndMembers; } } /// /// Returns the list of constraints for this association type /// [MetadataProperty(BuiltInTypeKind.ReferentialConstraint, true)] public ReadOnlyMetadataCollectionReferentialConstraints { get { return _referentialConstraints; } } #endregion #region Methods /// /// Validates a EdmMember object to determine if it can be added to this type's /// Members collection. If this method returns without throwing, it is assumed /// the member is valid. /// /// The member to validate ///Thrown if the member is not an AssociationEndMember internal override void ValidateMemberForAdd(EdmMember member) { if (!(member is AssociationEndMember)) { throw EntityUtil.AssociationInvalidMembers(); } } ////// Sets this item to be readonly, once this is set, the item will never be writable again. /// internal override void SetReadOnly() { if (!IsReadOnly) { base.SetReadOnly(); this.ReferentialConstraints.Source.SetReadOnly(); } } ////// Add the given referential constraint to the collection of referential constraints /// /// internal void AddReferentialConstraint(ReferentialConstraint referentialConstraint) { this.ReferentialConstraints.Source.Add(referentialConstraint); } #endregion } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....], [....] //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Data.Common; using System.Text; using System.Threading; using System.Diagnostics; namespace System.Data.Metadata.Edm { ////// Represents the Edm Association Type /// public sealed class AssociationType : RelationshipType { #region Constructors ////// Initializes a new instance of Association Type with the given name, namespace, version and ends /// /// name of the association type /// namespace of the association type /// version of the association type /// dataSpace in which this AssociationType belongs to ///Thrown if either the name, namespace or version attributes are null internal AssociationType(string name, string namespaceName, DataSpace dataSpace) : base(name, namespaceName, dataSpace) { _referentialConstraints = new ReadOnlyMetadataCollection(new MetadataCollection ()); } #endregion #region Fields private readonly ReadOnlyMetadataCollection _referentialConstraints; private FilteredReadOnlyMetadataCollection _associationEndMembers; #endregion #region Properties /// /// Returns the kind of the type /// public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.AssociationType; } } ////// Returns the list of ends for this association type /// public ReadOnlyMetadataCollectionAssociationEndMembers { get { Debug.Assert(IsReadOnly, "this is a wrapper around this.Members, don't call it during metadata loading, only call it after the metadata is set to readonly"); if (null == _associationEndMembers) { Interlocked.CompareExchange(ref _associationEndMembers, new FilteredReadOnlyMetadataCollection ( this.Members, Helper.IsAssociationEndMember), null); } return _associationEndMembers; } } /// /// Returns the list of constraints for this association type /// [MetadataProperty(BuiltInTypeKind.ReferentialConstraint, true)] public ReadOnlyMetadataCollectionReferentialConstraints { get { return _referentialConstraints; } } #endregion #region Methods /// /// Validates a EdmMember object to determine if it can be added to this type's /// Members collection. If this method returns without throwing, it is assumed /// the member is valid. /// /// The member to validate ///Thrown if the member is not an AssociationEndMember internal override void ValidateMemberForAdd(EdmMember member) { if (!(member is AssociationEndMember)) { throw EntityUtil.AssociationInvalidMembers(); } } ////// Sets this item to be readonly, once this is set, the item will never be writable again. /// internal override void SetReadOnly() { if (!IsReadOnly) { base.SetReadOnly(); this.ReferentialConstraints.Source.SetReadOnly(); } } ////// Add the given referential constraint to the collection of referential constraints /// /// internal void AddReferentialConstraint(ReferentialConstraint referentialConstraint) { this.ReferentialConstraints.Source.Add(referentialConstraint); } #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
- BulletedListEventArgs.cs
- OdbcConnectionString.cs
- CodeDomSerializer.cs
- ErrorFormatterPage.cs
- Line.cs
- ProfileModule.cs
- DataGridViewBindingCompleteEventArgs.cs
- DayRenderEvent.cs
- TdsRecordBufferSetter.cs
- SafeReversePInvokeHandle.cs
- HtmlFormWrapper.cs
- GifBitmapEncoder.cs
- nulltextnavigator.cs
- TextRunProperties.cs
- Durable.cs
- Attributes.cs
- Timeline.cs
- Context.cs
- HeaderFilter.cs
- BitmapEffect.cs
- Style.cs
- BufferManager.cs
- FloatUtil.cs
- ServiceDescription.cs
- PTProvider.cs
- BasicCellRelation.cs
- TiffBitmapDecoder.cs
- EffectiveValueEntry.cs
- DataGridBoolColumn.cs
- DefaultClaimSet.cs
- StylusDownEventArgs.cs
- InputLanguageProfileNotifySink.cs
- ArgumentValidation.cs
- CacheVirtualItemsEvent.cs
- ListViewDeleteEventArgs.cs
- SqlVersion.cs
- ListSourceHelper.cs
- RemotingConfiguration.cs
- login.cs
- TextEncodedRawTextWriter.cs
- ClassValidator.cs
- CapabilitiesState.cs
- FixedPageStructure.cs
- AmbientValueAttribute.cs
- CultureSpecificCharacterBufferRange.cs
- CircleHotSpot.cs
- HtmlTernaryTree.cs
- HtmlElementErrorEventArgs.cs
- PropertyChangedEventArgs.cs
- Model3D.cs
- ImageButton.cs
- WindowsIdentity.cs
- DirtyTextRange.cs
- LoginUtil.cs
- WebContext.cs
- XmlSchemaSubstitutionGroup.cs
- ImageAttributes.cs
- SocketInformation.cs
- SynchronizationContext.cs
- Style.cs
- CustomValidator.cs
- BitmapFrameDecode.cs
- ProfileGroupSettingsCollection.cs
- OutputCacheSection.cs
- XmlValueConverter.cs
- TextDecorationCollection.cs
- DrawingContextDrawingContextWalker.cs
- EventHandlersStore.cs
- RNGCryptoServiceProvider.cs
- LocalValueEnumerator.cs
- PackagePartCollection.cs
- HandlerBase.cs
- ColorAnimationUsingKeyFrames.cs
- TdsValueSetter.cs
- QilUnary.cs
- AffineTransform3D.cs
- ChildTable.cs
- PrtTicket_Base.cs
- Path.cs
- MsmqAppDomainProtocolHandler.cs
- smtppermission.cs
- DrawingContext.cs
- DataGridColumn.cs
- DisplayMemberTemplateSelector.cs
- MouseEventArgs.cs
- Codec.cs
- HtmlTextArea.cs
- CodeIndexerExpression.cs
- MergeFilterQuery.cs
- ReflectTypeDescriptionProvider.cs
- ExpressionPrefixAttribute.cs
- PageParserFilter.cs
- UIHelper.cs
- Vector3DAnimation.cs
- EpmTargetTree.cs
- ValuePattern.cs
- QuaternionRotation3D.cs
- GridViewUpdatedEventArgs.cs
- PublisherIdentityPermission.cs
- DataTemplateKey.cs