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 / Metadata / Edm / AssociationType.cs / 1 / 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
- BackgroundWorker.cs
- BasePattern.cs
- SplitterPanelDesigner.cs
- EpmCustomContentSerializer.cs
- PropertyMapper.cs
- StructuredTypeEmitter.cs
- FontUnitConverter.cs
- IsolationInterop.cs
- FormViewInsertEventArgs.cs
- VersionPair.cs
- OdbcRowUpdatingEvent.cs
- BlockCollection.cs
- NavigationProperty.cs
- HuffCodec.cs
- ProviderSettings.cs
- RunWorkerCompletedEventArgs.cs
- EmptyElement.cs
- TextSchema.cs
- TcpTransportSecurityElement.cs
- ObjectSecurity.cs
- SerialStream.cs
- basecomparevalidator.cs
- TextPatternIdentifiers.cs
- EncodingDataItem.cs
- SpecialNameAttribute.cs
- AsyncResult.cs
- WebPartDeleteVerb.cs
- DragDropHelper.cs
- KerberosTicketHashIdentifierClause.cs
- DataViewManagerListItemTypeDescriptor.cs
- UnsafeNativeMethods.cs
- AccessControlList.cs
- DesignerDataRelationship.cs
- Int32RectValueSerializer.cs
- Lookup.cs
- DetailsViewPageEventArgs.cs
- ActionNotSupportedException.cs
- UserControlBuildProvider.cs
- TaiwanCalendar.cs
- DataSourceSelectArguments.cs
- ConfigurationManagerHelper.cs
- DataTableTypeConverter.cs
- ObfuscateAssemblyAttribute.cs
- PixelFormatConverter.cs
- Semaphore.cs
- TextSelectionHelper.cs
- LambdaCompiler.Generated.cs
- WebServiceData.cs
- XpsFont.cs
- CollectionsUtil.cs
- GroupItemAutomationPeer.cs
- TextElementEditingBehaviorAttribute.cs
- DbConnectionPoolIdentity.cs
- DrawingAttributes.cs
- ThemeableAttribute.cs
- BuildProvider.cs
- PlanCompilerUtil.cs
- PenCursorManager.cs
- Matrix.cs
- LockedActivityGlyph.cs
- QuaternionAnimation.cs
- EventSinkHelperWriter.cs
- TableItemStyle.cs
- XpsResource.cs
- SettingsSavedEventArgs.cs
- ToolStripContainerDesigner.cs
- GlobalProxySelection.cs
- ControlDesignerState.cs
- DateTime.cs
- HtmlInputRadioButton.cs
- RijndaelManagedTransform.cs
- __ConsoleStream.cs
- GatewayDefinition.cs
- DataListItem.cs
- DataTableNewRowEvent.cs
- DiscoveryMessageSequence11.cs
- XmlCodeExporter.cs
- DataServiceQueryContinuation.cs
- ConvertTextFrag.cs
- AliasGenerator.cs
- TdsRecordBufferSetter.cs
- NonVisualControlAttribute.cs
- SoundPlayer.cs
- PersonalizationProviderCollection.cs
- DesignerDataView.cs
- SiteOfOriginContainer.cs
- XmlHierarchicalDataSourceView.cs
- CryptoConfig.cs
- Int32.cs
- ModuleBuilder.cs
- InternalTypeHelper.cs
- ListViewSelectEventArgs.cs
- StrokeFIndices.cs
- CatalogZoneBase.cs
- XmlSchemaExternal.cs
- TextDecorationCollectionConverter.cs
- OracleException.cs
- XmlMembersMapping.cs
- DataSourceHelper.cs
- HandleExceptionArgs.cs