File: AssociationSetEnd.cs

package info (click to toggle)
mono 6.14.1%2Bds2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,282,732 kB
  • sloc: cs: 11,182,461; xml: 2,850,281; ansic: 699,123; cpp: 122,919; perl: 58,604; javascript: 30,841; asm: 21,845; makefile: 19,602; sh: 10,973; python: 4,772; pascal: 925; sql: 859; sed: 16; php: 1
file content (169 lines) | stat: -rw-r--r-- 5,940 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
//---------------------------------------------------------------------
// <copyright file="AssociationSetEnd.cs" company="Microsoft">
//      Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//
// @owner       Microsoft
// @backupOwner Microsoft
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Text;


namespace System.Data.Metadata.Edm
{
    /// <summary>
    /// Class representing a AssociationSet End
    /// </summary>
    public sealed class AssociationSetEnd : MetadataItem
    {
        #region Constructors
        /// <summary>
        /// Initializes a new instance of AssocationSetEnd
        /// </summary>
        /// <param name="entitySet">Entity set that this end refers to</param>
        /// <param name="parentSet">The association set which this belongs to</param>
        /// <param name="endMember">The end member of the association set which this is an instance of</param>
        /// <exception cref="System.ArgumentNullException">Thrown if either the role,entitySet, parentSet or endMember arguments are null </exception>
        internal AssociationSetEnd(EntitySet entitySet, AssociationSet parentSet, AssociationEndMember endMember)
        {
            _entitySet = EntityUtil.GenericCheckArgumentNull(entitySet, "entitySet");
            _parentSet = EntityUtil.GenericCheckArgumentNull(parentSet, "parentSet");
            _endMember = EntityUtil.GenericCheckArgumentNull(endMember, "endMember");
        }
        #endregion

        #region Fields
        private readonly EntitySet _entitySet;
        private readonly AssociationSet _parentSet;
        private readonly AssociationEndMember _endMember;
        #endregion

        #region Properties
        /// <summary>
        /// Returns the kind of the type
        /// </summary>
        public override BuiltInTypeKind BuiltInTypeKind { get { return BuiltInTypeKind.AssociationSetEnd; } }

        /// <summary>
        /// The parent association set for this AssociationSetEnd.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">Thrown if the value passed in for the setter is null </exception>
        /// <exception cref="System.InvalidOperationException">Thrown if Setter is called when the AssociationSetEnd instance is in ReadOnly state</exception>
        [MetadataProperty(BuiltInTypeKind.AssociationSet, false)]
        public AssociationSet ParentAssociationSet
        {
            get
            {
                return _parentSet;
            }
        }

        /// <summary>
        /// The EndMember which this AssociationSetEnd corresponds to.
        /// </summary>
        /// <exception cref="System.ArgumentNullException">Thrown if the value passed in for the setter is null </exception>
        /// <exception cref="System.InvalidOperationException">Thrown if Setter is called when the AssociationSetEnd instance is in ReadOnly state</exception>
        [MetadataProperty(BuiltInTypeKind.AssociationEndMember, false)]
        public AssociationEndMember CorrespondingAssociationEndMember
        {
            get
            {
                return _endMember;
            }
        }

        /// <summary>
        /// Name of the end
        /// </summary>
        [MetadataProperty(PrimitiveTypeKind.String, false)]
        public string Name
        {
            get
            {
                return CorrespondingAssociationEndMember.Name;
            }
        }

        /// <summary>
        /// Name of the end role
        /// </summary>
        /// <exception cref="System.ArgumentNullException">Thrown if the value passed in for the setter is null </exception>
        /// <exception cref="System.InvalidOperationException">Thrown if Setter is called when the AssociationSetEnd instance is in ReadOnly state</exception>
        [MetadataProperty(PrimitiveTypeKind.String, false)]
        [Obsolete("This property is going away, please use the Name property instead")]
        public string Role
        {
            get
            {
                return Name;
            }
        }

        /// <summary>
        /// Returns the entity set referred by this end role
        /// </summary>
        [MetadataProperty(BuiltInTypeKind.EntitySet, false)]
        public EntitySet EntitySet
        {
            get
            {
                return _entitySet;
            }
        }

        /// <summary>
        /// Gets the identity of this item
        /// </summary>
        internal override string Identity
        {
            get
            {
                return this.Name;
            }
        }
        #endregion

        #region Methods
        /// <summary>
        /// Overriding System.Object.ToString to provide better String representation 
        /// for this type.
        /// </summary>
        public override string ToString()
        {
            return Name;
        }

        /// <summary>
        /// Sets this item to be readonly, once this is set, the item will never be writable again.
        /// </summary>
        internal override void SetReadOnly()
        {
            if (!IsReadOnly)
            {
                base.SetReadOnly();

                AssociationSet parentAssociationSet = ParentAssociationSet;
                if (parentAssociationSet != null)
                {
                    parentAssociationSet.SetReadOnly();
                }

                AssociationEndMember endMember = CorrespondingAssociationEndMember;
                if (endMember != null)
                {
                    endMember.SetReadOnly();
                }

                EntitySet entitySet = EntitySet;
                if (entitySet != null)
                {
                    entitySet.SetReadOnly();
                }
            }
        }
        #endregion
    }
}