public static string GetDescription(this VideoQuality value) { Type type = value.GetType(); string Name = Enum.GetName(type, value); if (Name != null) { System.Reflection.FieldInfo field = type.GetField(Name); if (field != null) { if (Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) is DescriptionAttribute attr) { return(attr.Description); } } } return(value.ToString()); }
public static int GetResolutionY(this VideoQuality item) { Type type = item.GetType(); string itemName = Enum.GetName(type, item); if (itemName != null) { System.Reflection.FieldInfo itemField = type.GetField(itemName); if (itemField != null) { if (Attribute.GetCustomAttribute(itemField, typeof(DescriptorAttribute)) is DescriptorAttribute attr) { return(attr.ResolutionY); } } } return(-1); }