C# Class EnumsNET.NonGeneric.NonGenericEnums

A non-generic implementation of the static class Enums. When the type is known at compile-time the Enums class should be used instead, to provide type safety and to avoid boxing.
ファイルを表示 Open project: TylerBrinkley/Enums.NET Class Usage Examples

Public Methods

Method Description
AsString ( Type enumType, object value ) : string

Converts the specified value to its string representation.

AsString ( Type enumType, object value, EnumFormat format ) : string

Converts the specified value to its string representation using the specified format.

AsString ( Type enumType, object value, EnumFormat format0, EnumFormat format1 ) : string

Converts the specified value to its string representation using the specified formats.

AsString ( Type enumType, object value, EnumFormat format0, EnumFormat format1, EnumFormat format2 ) : string

Converts the specified value to its string representation using the specified formats.

AsString ( Type enumType, object value, string format ) : string

Converts the specified value to its string representation using the specified format.

CompareTo ( Type enumType, object value, object other ) : int

Compares value to other for ordering.

Equals ( Type enumType, object value, object other ) : bool

Indicates if value equals other.

Format ( Type enumType, object value ) : string

Converts the specified value to its string representation using the specified formats.

Format ( Type enumType, object value, string format ) : string

Converts the specified value to its string representation using the specified format.

GetMember ( Type enumType, object value ) : EnumMember

Retrieves an enum member with the specified value if defined otherwise null.

GetMember ( Type enumType, string name ) : EnumMember

Retrieves the enum member with the specified name if defined otherwise null. Is case-sensitive.

GetMember ( Type enumType, string name, bool ignoreCase ) : EnumMember

Retrieves the enum member with the specified name if defined otherwise null. The parameter ignoreCase specifies if the operation is case-insensitive.

GetMemberCount ( Type enumType ) : int

Retrieves enumType's member count.

GetMemberCount ( Type enumType, EnumMemberSelection selection ) : int

Retrieves enumType's member count. The parameter selection indicates what members to include.

GetMembers ( Type enumType ) : IEnumerable

Retrieves enumType's members in increasing value order.

GetMembers ( Type enumType, EnumMemberSelection selection ) : IEnumerable

Retrieves enumType's members in increasing value order. The parameter selection indicates what members to include.

GetName ( Type enumType, object value ) : string

Retrieves value's enum member name if defined otherwise null.

GetNames ( Type enumType ) : IEnumerable

Retrieves enumType's members' names in increasing value order.

GetNames ( Type enumType, EnumMemberSelection selection ) : IEnumerable

Retrieves enumType's members' names in increasing value order. The parameter selection indicates what members to include.

GetTypeCode ( Type enumType ) : TypeCode

Retrieves enumType's underlying type's TypeCode.

GetUnderlyingType ( Type enumType ) : Type

Retrieves the underlying type of enumType.

GetUnderlyingValue ( Type enumType, object value ) : object

Returns value's underlying integral value.

GetValues ( Type enumType ) : IEnumerable

Retrieves enumType's members' values in increasing value order.

GetValues ( Type enumType, EnumMemberSelection selection ) : IEnumerable

Retrieves enumType's members' values in increasing value order. The parameter selection indicates what members to include.

IsDefined ( Type enumType, object value ) : bool

Indicates if value is defined.

IsValid ( Type enumType, object value ) : bool

Indicates if value is valid. If enumType is a standard enum it returns whether the value is defined. If enumType is marked with FlagsAttribute it returns whether it's a valid flag combination of enumType's defined values or is defined. Or if enumType has an attribute that implements IEnumValidatorAttribute{TEnum} then that attribute's IEnumValidatorAttribute{TEnum}.IsValid(TEnum) method is used.

Parse ( Type enumType, string value ) : object

Converts the string representation of one or more member names or values of enumType to its respective value of type enumType.

Parse ( Type enumType, string value, bool ignoreCase ) : object

Converts the string representation of one or more member names or values of enumType to its respective value of type enumType. The parameter ignoreCase specifies if the operation is case-insensitive.

ToByte ( Type enumType, object value ) : byte

Converts value to a byte.

ToInt16 ( Type enumType, object value ) : short

Converts value to an short.

ToInt32 ( Type enumType, object value ) : int

Converts value to an int.

ToInt64 ( Type enumType, object value ) : long

Converts value to an long.

ToObject ( Type enumType, byte value ) : object

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type.

ToObject ( Type enumType, byte value, bool validate ) : object

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid.

ToObject ( Type enumType, int value ) : object

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type.

ToObject ( Type enumType, int value, bool validate ) : object

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid.

ToObject ( Type enumType, long value ) : object

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type.

ToObject ( Type enumType, long value, bool validate ) : object

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid.

ToObject ( Type enumType, object value ) : object

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type.

ToObject ( Type enumType, object value, bool validate ) : object

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid.

ToObject ( Type enumType, short value ) : object

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type.

ToObject ( Type enumType, short value, bool validate ) : object

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid.

TryParse ( Type enumType, string value, bool ignoreCase, object &result ) : bool

Tries to convert the string representation of one or more member names or values of enumType to its respective value of type enumType. The parameter ignoreCase specifies whether the operation is case-insensitive. The return value indicates whether the conversion succeeded.

TryParse ( Type enumType, string value, object &result ) : bool

Tries to convert the string representation of one or more member names or values of enumType to its respective value of type enumType. The return value indicates whether the conversion succeeded.

TryToObject ( Type enumType, byte value, bool validate, object &result ) : bool

Tries to converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid. The return value indicates whether the conversion succeeded.

TryToObject ( Type enumType, byte value, object &result ) : bool

Tries to convert the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The return value indicates whether the conversion succeeded.

TryToObject ( Type enumType, int value, bool validate, object &result ) : bool

Tries to converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid. The return value indicates whether the conversion succeeded.

TryToObject ( Type enumType, int value, object &result ) : bool

Tries to convert the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The return value indicates whether the conversion succeeded.

TryToObject ( Type enumType, long value, bool validate, object &result ) : bool

Tries to converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid. The return value indicates whether the conversion succeeded.

TryToObject ( Type enumType, long value, object &result ) : bool

Tries to convert the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The return value indicates whether the conversion succeeded.

TryToObject ( Type enumType, object value, bool validate, object &result ) : bool

Tries to converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid. The return value indicates whether the conversion succeeded.

TryToObject ( Type enumType, object value, object &result ) : bool

Tries to convert the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The return value indicates whether the conversion succeeded.

TryToObject ( Type enumType, short value, bool validate, object &result ) : bool

Tries to converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid. The return value indicates whether the conversion succeeded.

TryToObject ( Type enumType, short value, object &result ) : bool

Tries to convert the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The return value indicates whether the conversion succeeded.

Validate ( Type enumType, object value, string paramName ) : object

Validates that value is valid. If it's not it throws an ArgumentException with the specified paramName.

Private Methods

Method Description
CompareToInternal ( NonGenericEnumInfo info, object value, object other ) : int
EqualsInternal ( NonGenericEnumInfo info, object value, object other ) : bool
GetEnumMember ( Type enumType, object value ) : EnumMember
GetEnumMember ( Type enumType, string name ) : EnumMember
GetEnumMember ( Type enumType, string name, bool ignoreCase ) : EnumMember
GetEnumMemberCount ( Type enumType ) : int
GetEnumMemberCount ( Type enumType, bool excludeDuplicates ) : int
GetEnumMembers ( Type enumType ) : IEnumerable
GetEnumMembers ( Type enumType, bool excludeDuplicates ) : IEnumerable
GetInfo ( Type enumType ) : IEnumInfo
GetNames ( Type enumType, bool excludeDuplicates ) : IEnumerable
GetNonGenericEnumInfo ( Type enumType ) : NonGenericEnumInfo
GetValues ( Type enumType, bool excludeDuplicates ) : IEnumerable
ToObject ( Type enumType, sbyte value ) : object
ToObject ( Type enumType, sbyte value, bool validate ) : object
ToObject ( Type enumType, uint value ) : object
ToObject ( Type enumType, uint value, bool validate ) : object
ToObject ( Type enumType, ulong value ) : object
ToObject ( Type enumType, ulong value, bool validate ) : object
ToObject ( Type enumType, ushort value ) : object
ToObject ( Type enumType, ushort value, bool validate ) : object
ToSByte ( Type enumType, object value ) : sbyte
ToUInt16 ( Type enumType, object value ) : ushort
ToUInt32 ( Type enumType, object value ) : uint
ToUInt64 ( Type enumType, object value ) : ulong
TryToObject ( Type enumType, sbyte value, bool validate, object &result ) : bool
TryToObject ( Type enumType, sbyte value, object &result ) : bool
TryToObject ( Type enumType, uint value, bool validate, object &result ) : bool
TryToObject ( Type enumType, uint value, object &result ) : bool
TryToObject ( Type enumType, ulong value, bool validate, object &result ) : bool
TryToObject ( Type enumType, ulong value, object &result ) : bool
TryToObject ( Type enumType, ushort value, bool validate, object &result ) : bool
TryToObject ( Type enumType, ushort value, object &result ) : bool

Method Details

AsString() public static method

Converts the specified value to its string representation.
or is null. is not an enum type /// -or- /// is of an invalid type.
public static AsString ( Type enumType, object value ) : string
enumType System.Type The enum type.
value object The enum value.
return string

AsString() public static method

Converts the specified value to its string representation using the specified format.
or is null. is not an enum type /// -or- /// is an invalid value.
public static AsString ( Type enumType, object value, EnumFormat format ) : string
enumType System.Type The enum type.
value object The enum value.
format EnumFormat The output format to use.
return string

AsString() public static method

Converts the specified value to its string representation using the specified formats.
or is null. is not an enum type /// -or- /// or is an invalid value.
public static AsString ( Type enumType, object value, EnumFormat format0, EnumFormat format1 ) : string
enumType System.Type The enum type.
value object The enum value.
format0 EnumFormat The first output format to use.
format1 EnumFormat The second output format to use if using the first resolves to null.
return string

AsString() public static method

Converts the specified value to its string representation using the specified formats.
or is null. is not an enum type /// -or- /// , , or is an invalid value.
public static AsString ( Type enumType, object value, EnumFormat format0, EnumFormat format1, EnumFormat format2 ) : string
enumType System.Type The enum type.
value object The enum value.
format0 EnumFormat The first output format to use.
format1 EnumFormat The second output format to use if using the first resolves to null.
format2 EnumFormat The third output format to use if using the first and second both resolve to null.
return string

AsString() public static method

Converts the specified value to its string representation using the specified format.
or is null. is not an enum type /// -or- /// is of an invalid type. is an invalid value.
public static AsString ( Type enumType, object value, string format ) : string
enumType System.Type The enum type.
value object The enum value.
format string The output format to use.
return string

CompareTo() public static method

Compares value to other for ordering.
, , or is null. is not an enum type /// -or- /// or is of an invalid type.
public static CompareTo ( Type enumType, object value, object other ) : int
enumType System.Type The enum type.
value object The enum value.
other object The other enum value.
return int

Equals() public static method

Indicates if value equals other.
, , or is null. is not an enum type /// -or- /// or is of an invalid type.
public static Equals ( Type enumType, object value, object other ) : bool
enumType System.Type The enum type.
value object The enum value.
other object The other enum value.
return bool

Format() public static method

Converts the specified value to its string representation using the specified formats.
, , or is null. is not an enum type /// -or- /// is of an invalid type /// -or- /// contains an invalid value.
public static Format ( Type enumType, object value ) : string
enumType System.Type The enum type.
value object The enum value.
return string

Format() public static method

Converts the specified value to its string representation using the specified format.
, , or is null. is not an enum type /// -or- /// is of an invalid type. is an invalid value.
public static Format ( Type enumType, object value, string format ) : string
enumType System.Type The enum type.
value object The enum value.
format string The output format to use.
return string

GetMember() public static method

Retrieves an enum member with the specified value if defined otherwise null.
or is null. is not an enum type /// -or- /// is of an invalid type.
public static GetMember ( Type enumType, object value ) : EnumMember
enumType System.Type The enum type.
value object The enum value.
return EnumMember

GetMember() public static method

Retrieves the enum member with the specified name if defined otherwise null. Is case-sensitive.
or is null. is not an enum type.
public static GetMember ( Type enumType, string name ) : EnumMember
enumType System.Type The enum type.
name string The enum member name.
return EnumMember

GetMember() public static method

Retrieves the enum member with the specified name if defined otherwise null. The parameter ignoreCase specifies if the operation is case-insensitive.
or is null. is not an enum type.
public static GetMember ( Type enumType, string name, bool ignoreCase ) : EnumMember
enumType System.Type The enum type.
name string The enum member name.
ignoreCase bool Indicates if the operation is case-insensitive.
return EnumMember

GetMemberCount() public static method

Retrieves enumType's member count.
is null. is not an enum type.
public static GetMemberCount ( Type enumType ) : int
enumType System.Type The enum type.
return int

GetMemberCount() public static method

Retrieves enumType's member count. The parameter selection indicates what members to include.
is null. is not an enum type /// -or- /// is an invalid value.
public static GetMemberCount ( Type enumType, EnumMemberSelection selection ) : int
enumType System.Type The enum type.
selection EnumMemberSelection Indicates what members to include.
return int

GetMembers() public static method

Retrieves enumType's members in increasing value order.
is null. is not an enum type.
public static GetMembers ( Type enumType ) : IEnumerable
enumType System.Type The enum type.
return IEnumerable

GetMembers() public static method

Retrieves enumType's members in increasing value order. The parameter selection indicates what members to include.
is null. is not an enum type /// -or- /// is an invalid value.
public static GetMembers ( Type enumType, EnumMemberSelection selection ) : IEnumerable
enumType System.Type The enum type.
selection EnumMemberSelection Indicates what members to include.
return IEnumerable

GetName() public static method

Retrieves value's enum member name if defined otherwise null.
or is null. is not an enum type /// -or- /// is of an invalid type.
public static GetName ( Type enumType, object value ) : string
enumType System.Type The enum type.
value object The enum value.
return string

GetNames() public static method

Retrieves enumType's members' names in increasing value order.
is null. is not an enum type.
public static GetNames ( Type enumType ) : IEnumerable
enumType System.Type The enum type.
return IEnumerable

GetNames() public static method

Retrieves enumType's members' names in increasing value order. The parameter selection indicates what members to include.
is null. is not an enum type /// -or- /// is an invalid value.
public static GetNames ( Type enumType, EnumMemberSelection selection ) : IEnumerable
enumType System.Type The enum type.
selection EnumMemberSelection Indicates what members to include.
return IEnumerable

GetTypeCode() public static method

Retrieves enumType's underlying type's TypeCode.
is null. is not an enum type.
public static GetTypeCode ( Type enumType ) : TypeCode
enumType System.Type The enum type.
return TypeCode

GetUnderlyingType() public static method

Retrieves the underlying type of enumType.
is null. is not an enum type.
public static GetUnderlyingType ( Type enumType ) : Type
enumType System.Type The enum type.
return System.Type

GetUnderlyingValue() public static method

Returns value's underlying integral value.
or is null. is not an enum type /// -or- /// is of an invalid type.
public static GetUnderlyingValue ( Type enumType, object value ) : object
enumType System.Type The enum type.
value object The enum value.
return object

GetValues() public static method

Retrieves enumType's members' values in increasing value order.
is null. is not an enum type.
public static GetValues ( Type enumType ) : IEnumerable
enumType System.Type The enum type.
return IEnumerable

GetValues() public static method

Retrieves enumType's members' values in increasing value order. The parameter selection indicates what members to include.
is null. is not an enum type /// -or- /// is an invalid value.
public static GetValues ( Type enumType, EnumMemberSelection selection ) : IEnumerable
enumType System.Type The enum type.
selection EnumMemberSelection Indicates what members to include.
return IEnumerable

IsDefined() public static method

Indicates if value is defined.
or is null. is not an enum type /// -or- /// is of an invalid type.
public static IsDefined ( Type enumType, object value ) : bool
enumType System.Type The enum type.
value object The enum value.
return bool

IsValid() public static method

Indicates if value is valid. If enumType is a standard enum it returns whether the value is defined. If enumType is marked with FlagsAttribute it returns whether it's a valid flag combination of enumType's defined values or is defined. Or if enumType has an attribute that implements IEnumValidatorAttribute{TEnum} then that attribute's IEnumValidatorAttribute{TEnum}.IsValid(TEnum) method is used.
or is null. is not an enum type /// -or- /// is of an invalid type.
public static IsValid ( Type enumType, object value ) : bool
enumType System.Type The enum type.
value object The enum value.
return bool

Parse() public static method

Converts the string representation of one or more member names or values of enumType to its respective value of type enumType.
or is null. is not an enum type /// -or- /// doesn't represent a member name or value of . is outside the range of 's underlying type.
public static Parse ( Type enumType, string value ) : object
enumType System.Type The enum type.
value string The enum member names or values' string representation.
return object

Parse() public static method

Converts the string representation of one or more member names or values of enumType to its respective value of type enumType. The parameter ignoreCase specifies if the operation is case-insensitive.
or is null. is not an enum type /// -or- /// doesn't represent a member name or value of . is outside the range of the underlying type of .
public static Parse ( Type enumType, string value, bool ignoreCase ) : object
enumType System.Type The enum type.
value string The enum member names or values' string representation.
ignoreCase bool Indicates if the operation is case-insensitive.
return object

ToByte() public static method

Converts value to a byte.
or is null. is not an enum type /// -or- /// is of an invalid type. cannot fit within 's value range without overflowing.
public static ToByte ( Type enumType, object value ) : byte
enumType System.Type The enum type.
value object The enum value.
return byte

ToInt16() public static method

Converts value to an short.
or is null. is not an enum type /// -or- /// is of an invalid type. cannot fit within 's value range without overflowing.
public static ToInt16 ( Type enumType, object value ) : short
enumType System.Type The enum type.
value object The enum value.
return short

ToInt32() public static method

Converts value to an int.
or is null. is not an enum type /// -or- /// is of an invalid type. cannot fit within 's value range without overflowing.
public static ToInt32 ( Type enumType, object value ) : int
enumType System.Type The enum type.
value object The enum value.
return int

ToInt64() public static method

Converts value to an long.
or is null. is not an enum type /// -or- /// is of an invalid type. cannot fit within 's value range without overflowing.
public static ToInt64 ( Type enumType, object value ) : long
enumType System.Type The enum type.
value object The enum value.
return long

ToObject() public static method

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type.
is null. is not an enum type. is outside the underlying type's value range.
public static ToObject ( Type enumType, byte value ) : object
enumType System.Type The enum type.
value byte Value to convert.
return object

ToObject() public static method

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid.
is null. is not an enum type /// -or- /// is true and the result is not a valid value. is outside the underlying type's value range.
public static ToObject ( Type enumType, byte value, bool validate ) : object
enumType System.Type The enum type.
value byte Value to convert.
validate bool Indicates whether to check that the result is valid.
return object

ToObject() public static method

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type.
is null. is not an enum type. is outside the underlying type's value range.
public static ToObject ( Type enumType, int value ) : object
enumType System.Type The enum type.
value int Value to convert.
return object

ToObject() public static method

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid.
is null. is not an enum type /// -or- /// is true and the result is not a valid value. is outside the underlying type's value range.
public static ToObject ( Type enumType, int value, bool validate ) : object
enumType System.Type The enum type.
value int Value to convert.
validate bool Indicates whether to check that the result is valid.
return object

ToObject() public static method

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type.
is null. is not an enum type. is outside the underlying type's value range.
public static ToObject ( Type enumType, long value ) : object
enumType System.Type The enum type.
value long Value to convert.
return object

ToObject() public static method

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid.
is null. is not an enum type /// -or- /// is true and the result is not a valid value. is outside the underlying type's value range.
public static ToObject ( Type enumType, long value, bool validate ) : object
enumType System.Type The enum type.
value long Value to convert.
validate bool Indicates whether to check that the result is valid.
return object

ToObject() public static method

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type.
or is null. is not an enum type /// -or- /// is not a valid type. is outside the underlying type's value range.
public static ToObject ( Type enumType, object value ) : object
enumType System.Type The enum type.
value object Value to convert. Must be an , , , , /// , , , , , , or Nullable of one of these.
return object

ToObject() public static method

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid.
or is null. is not an enum type /// -or- /// is not a valid type /// -or- /// is true and the result is not a valid value. is outside the underlying type's value range.
public static ToObject ( Type enumType, object value, bool validate ) : object
enumType System.Type The enum type.
value object Value to convert. Must be an , , , , /// , , , , , , or Nullable of one of these.
validate bool Indicates whether to check that the result is valid.
return object

ToObject() public static method

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type.
is null. is not an enum type. is outside the underlying type's value range.
public static ToObject ( Type enumType, short value ) : object
enumType System.Type The enum type.
value short Value to convert.
return object

ToObject() public static method

Converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid.
is null. is not an enum type /// -or- /// is true and the result is not a valid value. is outside the underlying type's value range.
public static ToObject ( Type enumType, short value, bool validate ) : object
enumType System.Type The enum type.
value short Value to convert.
validate bool Indicates whether to check that the result is valid.
return object

TryParse() public static method

Tries to convert the string representation of one or more member names or values of enumType to its respective value of type enumType. The parameter ignoreCase specifies whether the operation is case-insensitive. The return value indicates whether the conversion succeeded.
is null. is not an enum type.
public static TryParse ( Type enumType, string value, bool ignoreCase, object &result ) : bool
enumType System.Type The enum type.
value string The enum member names or values' string representation.
ignoreCase bool Indicates if the operation is case-insensitive.
result object If the conversion succeeds this contains a value that is represented by .
return bool

TryParse() public static method

Tries to convert the string representation of one or more member names or values of enumType to its respective value of type enumType. The return value indicates whether the conversion succeeded.
is null. is not an enum type.
public static TryParse ( Type enumType, string value, object &result ) : bool
enumType System.Type The enum type.
value string The enum member names or values' string representation.
result object If the conversion succeeds this contains a value that is represented by .
return bool

TryToObject() public static method

Tries to converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid. The return value indicates whether the conversion succeeded.
is null. is not an enum type.
public static TryToObject ( Type enumType, byte value, bool validate, object &result ) : bool
enumType System.Type The enum type.
value byte Value to try to convert.
validate bool Indicates whether to check that the result is valid.
result object If the conversion succeeds this contains a value of type whose value is .
return bool

TryToObject() public static method

Tries to convert the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The return value indicates whether the conversion succeeded.
is null. is not an enum type.
public static TryToObject ( Type enumType, byte value, object &result ) : bool
enumType System.Type The enum type.
value byte Value to try to convert.
result object If the conversion succeeds this contains a value of type whose value is .
return bool

TryToObject() public static method

Tries to converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid. The return value indicates whether the conversion succeeded.
is null. is not an enum type.
public static TryToObject ( Type enumType, int value, bool validate, object &result ) : bool
enumType System.Type The enum type.
value int Value to try to convert.
validate bool Indicates whether to check that the result is valid.
result object If the conversion succeeds this contains a value of type whose value is .
return bool

TryToObject() public static method

Tries to convert the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The return value indicates whether the conversion succeeded.
is null. is not an enum type.
public static TryToObject ( Type enumType, int value, object &result ) : bool
enumType System.Type The enum type.
value int Value to try to convert.
result object If the conversion succeeds this contains a value of type whose value is .
return bool

TryToObject() public static method

Tries to converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid. The return value indicates whether the conversion succeeded.
is null. is not an enum type.
public static TryToObject ( Type enumType, long value, bool validate, object &result ) : bool
enumType System.Type The enum type.
value long Value to try to convert.
validate bool Indicates whether to check that the result is valid.
result object If the conversion succeeds this contains a value of type whose value is .
return bool

TryToObject() public static method

Tries to convert the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The return value indicates whether the conversion succeeded.
is null. is not an enum type.
public static TryToObject ( Type enumType, long value, object &result ) : bool
enumType System.Type The enum type.
value long Value to try to convert.
result object If the conversion succeeds this contains a value of type whose value is .
return bool

TryToObject() public static method

Tries to converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid. The return value indicates whether the conversion succeeded.
is null. is not an enum type.
public static TryToObject ( Type enumType, object value, bool validate, object &result ) : bool
enumType System.Type The enum type.
value object Value to try to convert. Must be an , , , , /// , , , , , , or Nullable of one of these.
validate bool Indicates whether to check that the result is valid.
result object If the conversion succeeds this contains a value of type whose value is .
return bool

TryToObject() public static method

Tries to convert the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The return value indicates whether the conversion succeeded.
is null. is not an enum type.
public static TryToObject ( Type enumType, object value, object &result ) : bool
enumType System.Type The enum type.
value object Value to try to convert. Must be an , , , , /// , , , , , , or Nullable of one of these.
result object If the conversion succeeds this contains a value of type whose value is .
return bool

TryToObject() public static method

Tries to converts the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The parameter validate specifies whether to check that the result is valid. The return value indicates whether the conversion succeeded.
is null. is not an enum type.
public static TryToObject ( Type enumType, short value, bool validate, object &result ) : bool
enumType System.Type The enum type.
value short Value to try to convert.
validate bool Indicates whether to check that the result is valid.
result object If the conversion succeeds this contains a value of type whose value is .
return bool

TryToObject() public static method

Tries to convert the specified value to a value of type enumType while checking that it doesn't overflow the underlying type. The return value indicates whether the conversion succeeded.
is null. is not an enum type.
public static TryToObject ( Type enumType, short value, object &result ) : bool
enumType System.Type The enum type.
value short Value to try to convert.
result object If the conversion succeeds this contains a value of type whose value is .
return bool

Validate() public static method

Validates that value is valid. If it's not it throws an ArgumentException with the specified paramName.
or is null. is not an enum type /// -or- /// is of an invalid type /// -or- /// is invalid.
public static Validate ( Type enumType, object value, string paramName ) : object
enumType System.Type The enum type.
value object The enum value.
paramName string The parameter name to be used if throwing an .
return object