Extends enumerations by allowing them to define alternate strings with the [EnumString("Alternate Name",true)] attribute, and support it through TryParse and ToPreferredString
More...
|
static T | Parse< T > (T en, string value, T defaultValue) |
| Attempts case-insensitive parsing of the specified enum. Returns the specified default value if parsing fails. Supports [EnumString("Alternate Value")] attributes and parses flags. If any segment of a comma-delimited list isn't parsed as either a number or string, defaultValue will be returned. More...
|
|
static T | Parse< T > (T en, string value) |
| Attempts case-insensitive parsing of the specified enum. Returns null if parsing failed. Supports [EnumString("Alternate Value")] attributes and parses flags. If any segment of a comma-delimited list isn't parsed as either a number or string, null will be returned. More...
|
|
static T | Parse< T > (string value) |
|
static string | ToPreferredString (Enum en, bool lowerCase) |
| Retuns the string representation for the given enumeration More...
|
|
Extends enumerations by allowing them to define alternate strings with the [EnumString("Alternate Name",true)] attribute, and support it through TryParse and ToPreferredString
Definition at line 27 of file Enum.cs.
static T ImageResizer.ExtensionMethods.EnumExtensions.Parse< T > |
( |
T |
en, |
|
|
string |
value, |
|
|
T |
defaultValue |
|
) |
| |
|
inlinestatic |
Attempts case-insensitive parsing of the specified enum. Returns the specified default value if parsing fails. Supports [EnumString("Alternate Value")] attributes and parses flags. If any segment of a comma-delimited list isn't parsed as either a number or string, defaultValue will be returned.
- Parameters
-
- Returns
- Type Constraints
-
T | : | struct | |
T | : | IConvertible | |
Definition at line 101 of file Enum.cs.
101 :
struct, IConvertible {
102 T? val = EnumExtensions.Parse<T>(en, value);
103 return val == null ? defaultValue : val.Value;
static T ImageResizer.ExtensionMethods.EnumExtensions.Parse< T > |
( |
T |
en, |
|
|
string |
value |
|
) |
| |
|
inlinestatic |
Attempts case-insensitive parsing of the specified enum. Returns null if parsing failed. Supports [EnumString("Alternate Value")] attributes and parses flags. If any segment of a comma-delimited list isn't parsed as either a number or string, null will be returned.
- Parameters
-
- Returns
- Type Constraints
-
T | : | struct | |
T | : | IConvertible | |
Definition at line 113 of file Enum.cs.
113 :
struct, IConvertible {
static T Parse< T >(T en, string value, T defaultValue)
Attempts case-insensitive parsing of the specified enum. Returns the specified default value if parsi...
static string ImageResizer.ExtensionMethods.EnumExtensions.ToPreferredString |
( |
Enum |
en, |
|
|
bool |
lowerCase |
|
) |
| |
|
inlinestatic |
Retuns the string representation for the given enumeration
- Parameters
-
- Returns
Definition at line 156 of file Enum.cs.
158 Type t = en.GetType();
159 bool isFlags =
false;
161 Dictionary<Enum,string> d = GetPreferredStrings(t);
166 if (!d.TryGetValue(en, out temp)) temp = en.ToString();
167 return lowerCase ? temp.ToLowerInvariant() : temp;
The documentation for this class was generated from the following file:
- C:/Users/nathanael/Documents/resizer/Core/ExtensionMethods/Enum.cs