Struct Enum<TEnum>
Provides strongly typed way to reflect enum type.
Inherited Members
Namespace: DotNext
Assembly: DotNext.dll
Syntax
[Serializable]
public struct Enum<TEnum> : IEquatable<TEnum>, IComparable<TEnum>, IFormattable, IEquatable<Enum<TEnum>>, ISerializable, IConvertible<TEnum>, ICustomAttributeProvider where TEnum : struct, Enum
Type Parameters
Name | Description |
---|---|
TEnum | Enum type to reflect. |
Fields
| Improve this Doc View SourceMaxValue
Maximum enum value.
Declaration
public static readonly Enum<TEnum> MaxValue
Field Value
Type | Description |
---|---|
Enum<TEnum> |
MinValue
Minimum enum value.
Declaration
public static readonly Enum<TEnum> MinValue
Field Value
Type | Description |
---|---|
Enum<TEnum> |
Properties
| Improve this Doc View SourceMembers
Gets declared enum members.
Declaration
public static IReadOnlyList<Enum<TEnum>> Members { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Enum<TEnum>> |
Name
Represents name of the enum member.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
String |
UnderlyingType
Gets the underlying type of the specified enumeration.
Declaration
public static Type UnderlyingType { get; }
Property Value
Type | Description |
---|---|
Type |
UnderlyingTypeCode
Gets code of the underlying primitive type.
Declaration
public static TypeCode UnderlyingTypeCode { get; }
Property Value
Type | Description |
---|---|
TypeCode |
Value
Represents value of the enum member.
Declaration
public TEnum Value { get; }
Property Value
Type | Description |
---|---|
TEnum |
Methods
| Improve this Doc View SourceCompareTo(TEnum)
Compares this enum value with other.
Declaration
public int CompareTo(TEnum other)
Parameters
Type | Name | Description |
---|---|---|
TEnum | other | Other value to compare. |
Returns
Type | Description |
---|---|
Int32 | Comparison result. |
Equals(TEnum)
Determines whether this value equals to the other enum value.
Declaration
public bool Equals(TEnum other)
Parameters
Type | Name | Description |
---|---|---|
TEnum | other | Other value to compare. |
Returns
Type | Description |
---|---|
Boolean | Equality check result. |
Equals(Enum<TEnum>)
Determines whether two enum members are equal.
Declaration
public bool Equals(Enum<TEnum> other)
Parameters
Type | Name | Description |
---|---|---|
Enum<TEnum> | other | Other member to compare. |
Returns
Type | Description |
---|---|
Boolean | true if this enum member is the same as other; otherwise, false. |
Equals(Object)
Determines whether this value equals to the other enum value.
Declaration
public override bool Equals(object other)
Parameters
Type | Name | Description |
---|---|---|
Object | other | Other value to compare. |
Returns
Type | Description |
---|---|
Boolean | Equality check result. |
Overrides
| Improve this Doc View SourceGetCustomAttribute<T>()
Retrieves a custom attribute of a specified type that is applied to this enum member.
Declaration
public T GetCustomAttribute<T>()
where T : Attribute
Returns
Type | Description |
---|---|
T | A custom attribute that matches |
Type Parameters
Name | Description |
---|---|
T | The type of attribute to search for. |
GetCustomAttributes<T>()
Retrieves a collection of custom attributes of a specified type that are applied to this enum member.
Declaration
public IEnumerable<T> GetCustomAttributes<T>()
where T : Attribute
Returns
Type | Description |
---|---|
IEnumerable<T> | A collection of the custom attributes that are applied to element and that match
|
Type Parameters
Name | Description |
---|---|
T | The type of attribute to search for. |
GetHashCode()
Gets hash code of the enum member.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | The hash code of the enum member. |
Overrides
| Improve this Doc View SourceGetMember(TEnum)
Gets enum member by its value.
Declaration
public static Enum<TEnum> GetMember(TEnum value)
Parameters
Type | Name | Description |
---|---|---|
TEnum | value | The enum value. |
Returns
Type | Description |
---|---|
Enum<TEnum> | The enum member. |
GetMember(String)
Gets enum member by its case-sensitive name.
Declaration
public static Enum<TEnum> GetMember(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the enum value. |
Returns
Type | Description |
---|---|
Enum<TEnum> | The enum member. |
Exceptions
Type | Condition |
---|---|
KeyNotFoundException | Enum member with the requested name doesn't exist in enum. |
IsDefined(TEnum)
Returns an indication whether a constant with a specified value exists in a enumeration of type TEnum
.
Declaration
public static bool IsDefined(TEnum value)
Parameters
Type | Name | Description |
---|---|---|
TEnum | value | The value of a constant in |
Returns
Type | Description |
---|---|
Boolean | true if a constant in |
IsDefined(String)
Returns an indication whether a constant with a specified name exists in a enumeration of type TEnum
.
Declaration
public static bool IsDefined(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of a constant in |
Returns
Type | Description |
---|---|
Boolean | true if a constant in |
IsDefined(Type, Boolean)
Indicates whether the one or more attributes of the specified type or of its derived types is applied to this enum value.
Declaration
public bool IsDefined(Type attributeType, bool inherit = false)
Parameters
Type | Name | Description |
---|---|---|
Type | attributeType | The type of custom attribute to search for. The search includes derived types. |
Boolean | inherit | true to search this member's inheritance chain to find the attributes; otherwise, false. |
Returns
Type | Description |
---|---|
Boolean | true if one or more instances of attributeType or any of its derived types is applied to this member; otherwise, false. |
IsFlag(TEnum)
Determines whether one or more bit fields associated with the current instance are set in the given value.
Declaration
public bool IsFlag(TEnum flags)
Parameters
Type | Name | Description |
---|---|---|
TEnum | flags | An enumeration value. |
Returns
Type | Description |
---|---|
Boolean | true, if Value bits are set in |
ToString()
Returns textual representation of the enum value.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | The textual representation of the enum value. |
Overrides
| Improve this Doc View SourceTryGetMember(TEnum, out Enum<TEnum>)
Attempts to retrieve enum member which constant value is equal to the given value.
Declaration
public static bool TryGetMember(TEnum value, out Enum<TEnum> member)
Parameters
Type | Name | Description |
---|---|---|
TEnum | value | Enum value. |
Enum<TEnum> | member | Enum member which constant value is equal to |
Returns
Type | Description |
---|---|
Boolean | true, if there are member declared the given constant value exist; otherwise, false. |
TryGetMember(String, out Enum<TEnum>)
Attempts to retrieve enum member which name is equal to the given value.
Declaration
public static bool TryGetMember(string name, out Enum<TEnum> member)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of a constant. |
Enum<TEnum> | member | Enum member which name is equal to |
Returns
Type | Description |
---|---|
Boolean | true, if there are member declared the given constant value exist; otherwise, false. |
Operators
| Improve this Doc View SourceEquality(Enum<TEnum>, Enum<TEnum>)
Determines whether two enum members are equal.
Declaration
public static bool operator ==(Enum<TEnum> first, Enum<TEnum> second)
Parameters
Type | Name | Description |
---|---|---|
Enum<TEnum> | first | The first member to compare. |
Enum<TEnum> | second | The second member to compare. |
Returns
Type | Description |
---|---|
Boolean | true if this enum member is the same as other; otherwise, false. |
Implicit(Enum<TEnum> to TEnum)
Converts typed enum wrapper into actual enum value.
Declaration
public static implicit operator TEnum(in Enum<TEnum> en)
Parameters
Type | Name | Description |
---|---|---|
Enum<TEnum> | en | Enum wrapper to convert. |
Returns
Type | Description |
---|---|
TEnum |
Inequality(Enum<TEnum>, Enum<TEnum>)
Determines whether two enum members are not equal.
Declaration
public static bool operator !=(Enum<TEnum> first, Enum<TEnum> second)
Parameters
Type | Name | Description |
---|---|---|
Enum<TEnum> | first | The first member to compare. |
Enum<TEnum> | second | The second member to compare. |
Returns
Type | Description |
---|---|
Boolean | true if this enum member is not the same as other; otherwise, false. |
Explicit Interface Implementations
| Improve this Doc View SourceIConvertible<TEnum>.Convert()
Declaration
TEnum IConvertible<TEnum>.Convert()
Returns
Type | Description |
---|---|
TEnum |
IFormattable.ToString(String, IFormatProvider)
Declaration
string IFormattable.ToString(string format, IFormatProvider provider)
Parameters
Type | Name | Description |
---|---|---|
String | format | |
IFormatProvider | provider |
Returns
Type | Description |
---|---|
String |
ICustomAttributeProvider.GetCustomAttributes(Boolean)
Declaration
object[] ICustomAttributeProvider.GetCustomAttributes(bool inherit)
Parameters
Type | Name | Description |
---|---|---|
Boolean | inherit |
Returns
Type | Description |
---|---|
Object[] |
ICustomAttributeProvider.GetCustomAttributes(Type, Boolean)
Declaration
object[] ICustomAttributeProvider.GetCustomAttributes(Type attributeType, bool inherit)
Parameters
Type | Name | Description |
---|---|---|
Type | attributeType | |
Boolean | inherit |
Returns
Type | Description |
---|---|
Object[] |
ISerializable.GetObjectData(SerializationInfo, StreamingContext)
Declaration
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
Parameters
Type | Name | Description |
---|---|---|
SerializationInfo | info | |
StreamingContext | context |