Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Metadata / Edm / AssociationType.cs / 1305376 / AssociationType.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
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
/// is this a foreign key (FK) relationship?
/// dataSpace in which this AssociationType belongs to
/// Thrown if either the name, namespace or version attributes are null
internal AssociationType(string name,
string namespaceName,
bool foreignKey,
DataSpace dataSpace)
: base(name, namespaceName, dataSpace)
{
_referentialConstraints = new ReadOnlyMetadataCollection(new MetadataCollection());
_isForeignKey = foreignKey;
}
#endregion
#region Fields
private readonly ReadOnlyMetadataCollection _referentialConstraints;
private FilteredReadOnlyMetadataCollection _associationEndMembers;
private readonly bool _isForeignKey;
#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 ReadOnlyMetadataCollection AssociationEndMembers
{
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 ReadOnlyMetadataCollection ReferentialConstraints
{
get
{
return _referentialConstraints;
}
}
///
/// Indicates whether this is a foreign key relationship.
///
[MetadataProperty(PrimitiveTypeKind.Boolean, false)]
public bool IsForeignKey
{
get
{
return _isForeignKey;
}
}
#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)
{
Debug.Assert(
(member is AssociationEndMember),
"Only members of type AssociationEndMember may be added to Association definitions.");
}
///
/// 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 [....]
// @backupOwner [....]
//---------------------------------------------------------------------
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
/// is this a foreign key (FK) relationship?
/// dataSpace in which this AssociationType belongs to
/// Thrown if either the name, namespace or version attributes are null
internal AssociationType(string name,
string namespaceName,
bool foreignKey,
DataSpace dataSpace)
: base(name, namespaceName, dataSpace)
{
_referentialConstraints = new ReadOnlyMetadataCollection(new MetadataCollection());
_isForeignKey = foreignKey;
}
#endregion
#region Fields
private readonly ReadOnlyMetadataCollection _referentialConstraints;
private FilteredReadOnlyMetadataCollection _associationEndMembers;
private readonly bool _isForeignKey;
#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 ReadOnlyMetadataCollection AssociationEndMembers
{
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 ReadOnlyMetadataCollection ReferentialConstraints
{
get
{
return _referentialConstraints;
}
}
///
/// Indicates whether this is a foreign key relationship.
///
[MetadataProperty(PrimitiveTypeKind.Boolean, false)]
public bool IsForeignKey
{
get
{
return _isForeignKey;
}
}
#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)
{
Debug.Assert(
(member is AssociationEndMember),
"Only members of type AssociationEndMember may be added to Association definitions.");
}
///
/// 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
- SetStoryboardSpeedRatio.cs
- QuaternionKeyFrameCollection.cs
- PeerNodeTraceRecord.cs
- SecurityException.cs
- Panel.cs
- SchemaNotation.cs
- StatusBarAutomationPeer.cs
- InputLanguageManager.cs
- SmtpException.cs
- Canvas.cs
- FrameworkElement.cs
- EventDescriptorCollection.cs
- BindingEntityInfo.cs
- MeasureItemEvent.cs
- figurelength.cs
- ECDiffieHellman.cs
- ScrollBar.cs
- RIPEMD160Managed.cs
- CodeDelegateInvokeExpression.cs
- AmbientLight.cs
- XPathNodeInfoAtom.cs
- Image.cs
- EngineSite.cs
- TemplateControlCodeDomTreeGenerator.cs
- ExceptionHandlersDesigner.cs
- ListViewTableCell.cs
- GeometryDrawing.cs
- TreeViewImageKeyConverter.cs
- DataGridViewCellContextMenuStripNeededEventArgs.cs
- ServiceDescriptionSerializer.cs
- Int64Storage.cs
- HasRunnableWorkflowEvent.cs
- CustomCategoryAttribute.cs
- SmtpReplyReaderFactory.cs
- ColorDialog.cs
- ObjectStateManagerMetadata.cs
- RuleSetReference.cs
- GridItemPatternIdentifiers.cs
- ContactManager.cs
- TCPListener.cs
- TraversalRequest.cs
- RegexGroup.cs
- XsltException.cs
- RequiredFieldValidator.cs
- ParserStreamGeometryContext.cs
- LoginUtil.cs
- ExceptionUtility.cs
- ButtonChrome.cs
- _FtpControlStream.cs
- HttpResponseInternalWrapper.cs
- CmsInterop.cs
- TypeCodeDomSerializer.cs
- AssemblyResourceLoader.cs
- WorkflowHostingEndpoint.cs
- ListViewEditEventArgs.cs
- LinqDataSourceEditData.cs
- ChangeToolStripParentVerb.cs
- DateTimeEditor.cs
- MultiView.cs
- UndoUnit.cs
- ThreadStartException.cs
- SqlGenerator.cs
- ExportOptions.cs
- SkewTransform.cs
- WorkflowFormatterBehavior.cs
- HttpCachePolicy.cs
- Size.cs
- ErrorFormatter.cs
- SecurityTokenTypes.cs
- updateconfighost.cs
- Resources.Designer.cs
- ByteArrayHelperWithString.cs
- ClientRoleProvider.cs
- Vector3DAnimation.cs
- ClientRoleProvider.cs
- XmlMtomReader.cs
- MimeTextImporter.cs
- XmlDocument.cs
- ProcessHostMapPath.cs
- Win32SafeHandles.cs
- AnnotationObservableCollection.cs
- StagingAreaInputItem.cs
- TemplateBindingExpressionConverter.cs
- templategroup.cs
- SplayTreeNode.cs
- ExtendedProtectionPolicyTypeConverter.cs
- FontDifferentiator.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- hebrewshape.cs
- TimerExtension.cs
- BamlLocalizableResource.cs
- StorageModelBuildProvider.cs
- TabControlCancelEvent.cs
- XmlLanguageConverter.cs
- WSHttpBindingCollectionElement.cs
- SvcMapFileSerializer.cs
- HyperlinkAutomationPeer.cs
- TypeSemantics.cs
- designeractionlistschangedeventargs.cs
- PolyLineSegment.cs