File: EnumMember.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 (118 lines) | stat: -rw-r--r-- 3,364 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
//---------------------------------------------------------------------
// <copyright file="EnumMember.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;
using System.Diagnostics;

namespace System.Data.Metadata.Edm
{
    /// <summary>
    /// Represents an enumeration member.
    /// </summary>
    public sealed class EnumMember : MetadataItem
    {
        #region Fields

        /// <summary>
        /// The name of this enumeration member.
        /// </summary>
        private readonly string _name;

        /// <summary>
        /// The value of this enumeration member.
        /// </summary>
        private readonly object _value;

        #endregion

        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="EnumMember"/> type by using the specified name and value.
        /// </summary>
        /// <param name="name">The name of this enumeration member. Must not be null or the empty string.</param>
        /// <param name="value">The value of this enumeration member. </param>
        /// <exception cref="System.ArgumentNullException">Thrown if name argument is null</exception>
        /// <exception cref="System.ArgumentException">Thrown if name argument is empty string</exception>
        internal EnumMember(string name, object value)
            : base(MetadataFlags.Readonly)
        {
            EntityUtil.CheckStringArgument(name, "name");
            Debug.Assert(value != null, "value != null");
            Debug.Assert(value is SByte || value is Byte || value is Int16 || value is Int32 || value is Int64, "Unsupported type of enum member value.");

            _name = name;
            _value = value;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets the kind of this type.
        /// </summary>
        public override BuiltInTypeKind BuiltInTypeKind 
        { 
            get { return BuiltInTypeKind.EnumMember; } 
        }

        /// <summary>
        /// Gets the name of this enumeration member.
        /// </summary>
        [MetadataProperty(PrimitiveTypeKind.String, false)]
        public string Name
        {
            get
            {
                return _name;
            }
        }

        /// <summary>
        /// Gets the value of this enumeration member.
        /// </summary>
        [MetadataProperty(BuiltInTypeKind.PrimitiveType, false)]
        public object Value
        {
            get
            {
                return _value;
            }
        }

        /// <summary>
        /// Gets the identity for this item as a string
        /// </summary>
        internal override string Identity
        {
            get
            {
                return Name;
            }
        }

        #endregion

        #region Methods

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

        #endregion
    }
}