internal static string RarityString(this MagicItemRarity rarity) { switch (rarity) { case MagicItemRarity.VeryRare: return("Very Rare"); case MagicItemRarity.Undefined: throw new IndexOutOfRangeException("Unexpected Error getting rarity string - Rarity Undefined: " + rarity.ToString()); default: return(rarity.ToString()); } }
public static string Description(this MagicItemRarity val) { DescriptionAttribute[] attributes = (DescriptionAttribute[])val.GetType().GetField(val.ToString()).GetCustomAttributes(typeof(DescriptionAttribute), false); return(attributes.Length > 0 ? attributes[0].Description : string.Empty); }