예제 #1
0
        public static string GetDescription(this Type type, string fieldName)
        {
            var typeDisplay = typeof(DescriptionAttribute);
            var attributes  = new DescriptionAttribute[0];

            try
            {
                var field = type.GetField(fieldName);
                var arr   = field.GetCustomAttributes(typeDisplay, true);
                attributes = arr.OfType <DescriptionAttribute>().ToArray();
                var attribute = attributes.FirstOrDefault();
                return(attribute.Description);
            }
            catch
            {
                return("");
            }
        }