/// <summary> /// Convierte el enumerado a su nombre asociado en [Description] /// </summary> /// <param name="value"></param> /// <returns></returns> public static string ToName(this System.Enum value) { if (value == null) { return(string.Empty); } var attribute = value.GetAttribute <DescriptionAttribute>(); return(attribute?.Description ?? value.ToString()); }
/// <summary> /// Gets the registry key for an enumeration member, or null if it is not set. /// </summary> /// <param name="enum">The enumeration member.</param> /// <returns>The registry key attribute for the member, or null if it is not set.</returns> public static string GetRegistryKey(Enum @enum) { var registryKeyAttribute = @enum.GetAttribute<RegistryKeyAttribute>(); return registryKeyAttribute != null ? registryKeyAttribute.RegistryKey : null; }
// This method creates a specific call to the above method, requesting the // Description MetaData attribute. /// <summary> /// Converts to description. /// </summary> /// <param name="value">The value.</param> /// <returns></returns> public static string ToDescription(this System.Enum value) { DescriptionAttribute attribute = value.GetAttribute <DescriptionAttribute>(); return(attribute == null?value.ToString() : attribute.Description); }
public static string GetDescription(this Enum enumvValue) { return(enumvValue?.GetAttribute <DescriptionAttribute>()?.Description ?? enumvValue?.ToString() ?? string.Empty); }
public static String GetCode(Enum value) { return value.GetAttribute<CodeAttribute>().Value; }
/// <summary> /// Get description attribute of enum /// </summary> /// <param name="value"></param> /// <returns></returns> public static string GetDescription(this System.Enum value) { return(value.GetAttribute <DescriptionAttribute>().Description); }