//---------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
namespace System.Data.Metadata.Edm
{
///
/// Class for representing an Association set
///
public sealed class AssociationSet : RelationshipSet
{
#region Constructors
///
/// Initializes a new instance of AssocationSet with the given name and the association type
///
/// The name of the Assocation set
/// The association type of the entities that this associationship set type contains
internal AssociationSet(string name, AssociationType associationType)
: base(name, null, null, null, associationType)
{
}
#endregion
#region Fields
private readonly ReadOnlyMetadataCollection _associationSetEnds =
new ReadOnlyMetadataCollection(new MetadataCollection());
#endregion
#region Properties
///
/// Returns the association type associated with this association set
///
public new AssociationType ElementType
{
get
{
return (AssociationType)base.ElementType;
}
}
///
/// Returns the ends of the association set
///
[MetadataProperty(BuiltInTypeKind.AssociationSetEnd, true)]
public ReadOnlyMetadataCollection AssociationSetEnds
{
get
{
return _associationSetEnds;
}
}
///
/// Returns the kind of the type
///
public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.AssociationSet; } }
#endregion
#region Methods
///
/// Sets this item to be readonly, once this is set, the item will never be writable again.
///
internal override void SetReadOnly()
{
if (!this.IsReadOnly)
{
base.SetReadOnly();
this.AssociationSetEnds.Source.SetReadOnly();
}
}
///
/// Adds the given end to the collection of ends
///
///
internal void AddAssociationSetEnd(AssociationSetEnd associationSetEnd)
{
this.AssociationSetEnds.Source.Add(associationSetEnd);
}
#endregion
}
}