Beispiel #1
0
        /// <summary>
        /// Get DescriptionAttribute item emnun
        /// </summary>
        /// <param name="gameOption"></param>
        /// <returns></returns>
        public static String GetDescription(this GameOption gameOption)
        {
            Type type = gameOption.GetType();

            MemberInfo[] memberInfo = type.GetMember(gameOption.ToString());
            if (memberInfo != null && memberInfo.Length > 0)
            {
                object[] attrs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);
                if (attrs != null && attrs.Length > 0)
                {
                    return(((DescriptionAttribute)attrs[0]).Description);
                }
            }            //if
            return(gameOption.ToString());
        }