Ejemplo n.º 1
0
 public static T FromChar <T>(string caracter) where T : struct, IConvertible
 {
     return(EnumExtensions.FromChar <T>(caracter[0]));
 }
 /// <summary>Obtains the EnumMemberAttribute.Value property or enumeration ToString().</summary>
 /// <typeparam name="T">Type of enumeration being passed in.</typeparam>
 /// <param name="resourceType">Value of the enumeration being passed in.</param>
 /// <returns>EnumMemberAttribute or resourceType.ToString().</returns>
 public static string ToAttributeValue <T>(this T resourceType) where T : struct, IConvertible
 {
     return(EnumExtensions.ToAttributeValue(typeof(T), resourceType as Enum));
 }
 /// <summary>Parses a string and converts to an enumeration.</summary>
 /// <typeparam name="T">Type of enumeration to return.</typeparam>
 /// <param name="fieldValue">EnumMemberAttribute.Value string or enum.ToString().</param>
 /// <returns>Enumeration of the correct value.</returns>
 public static T ToEnum <T>(string fieldValue) where T : struct, IConvertible
 {
     return((T)(object)EnumExtensions.ToEnum(typeof(T), fieldValue));
 }
Ejemplo n.º 4
0
 /// <summary>Parses a string and converts to an enumeration.</summary>
 /// <typeparam name="T">Type of enumeration to return.</typeparam>
 /// <param name="fieldValue">String value.</param>
 /// <param name="defaultValue">Default value to use if the EnumMemberAttribute is not obtained.</param>
 /// <returns>Enumeration of the correct value.</returns>
 public static T ToEnum <T>(this string fieldValue, T defaultValue) where T : struct, IConvertible
 {
     return(EnumExtensions.ToEnum <T>(fieldValue, defaultValue));
 }