Class EnumExtensions
- Namespace
- TechnologySolutions.Rfid.AsciiProtocol
- Assembly
- TechnologySolutions.Rfid.AsciiProtocol.Core.dll
Extension methods for the parameter Enumerations
public static class EnumExtensions
- Inheritance
-
EnumExtensions
- Inherited Members
Methods
Description(Enum)
Returns the description for the specified value
public static string Description(this Enum value)
Parameters
value
EnumThe value of interest
Returns
- string
The description for the value
IsValid(Enum)
Returns a value indicating whether value is defined in the Enum
public static bool IsValid(this Enum value)
Parameters
value
EnumThe value to test
Returns
- bool
True if the value is defined in the Enum
Parameter(Enum)
Returns the parameter for the specified value
public static string Parameter(this Enum value)
Parameters
value
EnumThe value of interest
Returns
- string
The parameter for the value
ParseNumericParameterAs<TEnum>(string)
Expects a string as a decimal value converts to an int then casts to the enum type
public static TEnum ParseNumericParameterAs<TEnum>(this string parameter)
Parameters
parameter
stringThe parameter value to match
Returns
- TEnum
The first value in the enum that has a matching parameter
Type Parameters
TEnum
The type of the enum required
Exceptions
- FormatException
If parameter is not recognised for that enum
ParseParameterAs<TEnum>(string)
Returns the first value of the specified enum type that has a matching parameter
public static TEnum ParseParameterAs<TEnum>(this string parameter)
Parameters
parameter
stringThe parameter value to match
Returns
- TEnum
The first value in the enum that has a matching parameter
Type Parameters
TEnum
The type of the enum required
Exceptions
- FormatException
If parameter is not recognised for that enum
Validate(Enum)
Throws an ArgumentOutOfRangeException is value is not one of the values of the enum
public static void Validate(this Enum value)
Parameters
value
EnumThe value to test
Exceptions
- ArgumentOutOfRangeException
If value is not a defined value