//---------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Text;
using System.Diagnostics;
namespace System.Data.Metadata.Edm
{
///
/// Represents an enumeration member.
///
public sealed class EnumMember : MetadataItem
{
#region Fields
///
/// The name of this enumeration member.
///
private readonly string _name;
///
/// The value of this enumeration member.
///
private readonly object _value;
#endregion
#region Constructors
///
/// Initializes a new instance of the type by using the specified name and value.
///
/// The name of this enumeration member. Must not be null or the empty string.
/// The value of this enumeration member.
/// Thrown if name argument is null
/// Thrown if name argument is empty string
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
///
/// Gets the kind of this type.
///
public override BuiltInTypeKind BuiltInTypeKind
{
get { return BuiltInTypeKind.EnumMember; }
}
///
/// Gets the name of this enumeration member.
///
[MetadataProperty(PrimitiveTypeKind.String, false)]
public string Name
{
get
{
return _name;
}
}
///
/// Gets the value of this enumeration member.
///
[MetadataProperty(BuiltInTypeKind.PrimitiveType, false)]
public object Value
{
get
{
return _value;
}
}
///
/// Gets the identity for this item as a string
///
internal override string Identity
{
get
{
return Name;
}
}
#endregion
#region Methods
///
/// Overriding System.Object.ToString to provide better String representation for this type.
///
public override string ToString()
{
return Name;
}
#endregion
}
}