Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="that"></param>
        /// <returns></returns>
        private static EnumDescriptionAttribute GetAttribute <T>(T that)
        {
            T v = that;

            object[] attr = v.GetType().GetField(v.ToString()).GetCustomAttributes(typeof(EnumDescriptionAttribute), true);
            if (attr.Length > 0)
            {
                foreach (object att in attr)
                {
                    EnumDescriptionAttribute ina = att as EnumDescriptionAttribute;
                    if (ina == null)
                    {
                        continue;
                    }
                    return(ina);
                }
            }
            return(null);
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ths"></param>
        /// <returns></returns>
        public static string InternalComment <T>(this T ths) where T : struct
        {
            EnumDescriptionAttribute att = GetAttribute(ths);

            return(att == null ? null : att.Comment);
        }