Updates referencesource to .NET 4.7
[mono-project.git] / mcs / class / referencesource / System.Data.Entity / System / Data / Metadata / Edm / AssociationSetEnd.cs
blobb6c5cbd435f70f76f31c13f41276599f6b3c0583
1 //---------------------------------------------------------------------
2 // <copyright file="AssociationSetEnd.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 // </copyright>
5 //
6 // @owner Microsoft
7 // @backupOwner Microsoft
8 //---------------------------------------------------------------------
9 using System;
10 using System.Collections.Generic;
11 using System.Data.Common;
12 using System.Text;
15 namespace System.Data.Metadata.Edm
17 /// <summary>
18 /// Class representing a AssociationSet End
19 /// </summary>
20 public sealed class AssociationSetEnd : MetadataItem
22 #region Constructors
23 /// <summary>
24 /// Initializes a new instance of AssocationSetEnd
25 /// </summary>
26 /// <param name="entitySet">Entity set that this end refers to</param>
27 /// <param name="parentSet">The association set which this belongs to</param>
28 /// <param name="endMember">The end member of the association set which this is an instance of</param>
29 /// <exception cref="System.ArgumentNullException">Thrown if either the role,entitySet, parentSet or endMember arguments are null </exception>
30 internal AssociationSetEnd(EntitySet entitySet, AssociationSet parentSet, AssociationEndMember endMember)
32 _entitySet = EntityUtil.GenericCheckArgumentNull(entitySet, "entitySet");
33 _parentSet = EntityUtil.GenericCheckArgumentNull(parentSet, "parentSet");
34 _endMember = EntityUtil.GenericCheckArgumentNull(endMember, "endMember");
36 #endregion
38 #region Fields
39 private readonly EntitySet _entitySet;
40 private readonly AssociationSet _parentSet;
41 private readonly AssociationEndMember _endMember;
42 #endregion
44 #region Properties
45 /// <summary>
46 /// Returns the kind of the type
47 /// </summary>
48 public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.AssociationSetEnd; } }
50 /// <summary>
51 /// The parent association set for this AssociationSetEnd.
52 /// </summary>
53 /// <exception cref="System.ArgumentNullException">Thrown if the value passed in for the setter is null </exception>
54 /// <exception cref="System.InvalidOperationException">Thrown if Setter is called when the AssociationSetEnd instance is in ReadOnly state</exception>
55 [MetadataProperty(BuiltInTypeKind.AssociationSet, false)]
56 public AssociationSet ParentAssociationSet
58 get
60 return _parentSet;
64 /// <summary>
65 /// The EndMember which this AssociationSetEnd corresponds to.
66 /// </summary>
67 /// <exception cref="System.ArgumentNullException">Thrown if the value passed in for the setter is null </exception>
68 /// <exception cref="System.InvalidOperationException">Thrown if Setter is called when the AssociationSetEnd instance is in ReadOnly state</exception>
69 [MetadataProperty(BuiltInTypeKind.AssociationEndMember, false)]
70 public AssociationEndMember CorrespondingAssociationEndMember
72 get
74 return _endMember;
78 /// <summary>
79 /// Name of the end
80 /// </summary>
81 [MetadataProperty(PrimitiveTypeKind.String, false)]
82 public string Name
84 get
86 return CorrespondingAssociationEndMember.Name;
90 /// <summary>
91 /// Name of the end role
92 /// </summary>
93 /// <exception cref="System.ArgumentNullException">Thrown if the value passed in for the setter is null </exception>
94 /// <exception cref="System.InvalidOperationException">Thrown if Setter is called when the AssociationSetEnd instance is in ReadOnly state</exception>
95 [MetadataProperty(PrimitiveTypeKind.String, false)]
96 [Obsolete("This property is going away, please use the Name property instead")]
97 public string Role
99 get
101 return Name;
105 /// <summary>
106 /// Returns the entity set referred by this end role
107 /// </summary>
108 [MetadataProperty(BuiltInTypeKind.EntitySet, false)]
109 public EntitySet EntitySet
113 return _entitySet;
117 /// <summary>
118 /// Gets the identity of this item
119 /// </summary>
120 internal override string Identity
124 return this.Name;
127 #endregion
129 #region Methods
130 /// <summary>
131 /// Overriding System.Object.ToString to provide better String representation
132 /// for this type.
133 /// </summary>
134 public override string ToString()
136 return Name;
139 /// <summary>
140 /// Sets this item to be readonly, once this is set, the item will never be writable again.
141 /// </summary>
142 internal override void SetReadOnly()
144 if (!IsReadOnly)
146 base.SetReadOnly();
148 AssociationSet parentAssociationSet = ParentAssociationSet;
149 if (parentAssociationSet != null)
151 parentAssociationSet.SetReadOnly();
154 AssociationEndMember endMember = CorrespondingAssociationEndMember;
155 if (endMember != null)
157 endMember.SetReadOnly();
160 EntitySet entitySet = EntitySet;
161 if (entitySet != null)
163 entitySet.SetReadOnly();
167 #endregion