public static string ToDescriptionString(this DeviceEnum val) { var attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); return(attributes.Length > 0 ? attributes[0].Description : string.Empty); }
public static string ToResourceName(this DeviceEnum val) { var attributes = (DeviceResourceNameAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DeviceResourceNameAttribute), false); return(attributes.Length > 0 ? attributes[0].ResourceName : string.Empty); }