public void DescribeIngredients() { Console.WriteLine(""); Console.WriteLine("---------------------------------------"); Console.WriteLine($"This pizza is a {Name}"); if (Dough != null) { Console.WriteLine($"Dough is {Dough.GetType().Name} "); } if (Sauce != null) { Console.WriteLine($"Sauce is {Sauce.GetType().Name} "); } if (Cheese != null) { Console.WriteLine($"Cheese is {Cheese.GetType().Name} "); } if (Meat != null) { Console.WriteLine($"Meat is {Meat.GetType().Name} "); } Console.WriteLine("---------------------------------------"); Console.WriteLine(""); }
public static string GetDescription(this Meat value) { var field = value.GetType().GetField(value.ToString()); var attribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute; return(attribute == null?value.ToString() : attribute.Description); }