示例#1
0
        private static string GetMenuOptionDisplay(MenuOptions option)
        {
            var fieldInfo = option.GetType().GetField(option.ToString());

            DisplayAttribute[] descriptionAttribute = fieldInfo.GetCustomAttributes(
                typeof(DisplayAttribute), false) as DisplayAttribute[];

            //If there is an Display attribute then return it, else retuen the option in string.
            return((descriptionAttribute.Length > 0) ? descriptionAttribute[0].Name : option.ToString());
        }