Exemplo n.º 1
0
        public static string ToShortNameString(this ICustomAttributeProvider cat)
        {
            var atrDisp = ReflexionUtils.GetAtribute <DisplayAttribute>(cat);

            if (atrDisp != null)
            {
                return(atrDisp.GetShortName());
            }

            if (cat is PropertyInfo)
            {
                return((cat as PropertyInfo).Name);
            }

            if (cat is MemberInfo)
            {
                return((cat as MemberInfo).Name);
            }

            if (cat is FieldInfo)
            {
                return((cat as FieldInfo).Name);
            }

            if (cat is Type)
            {
                return((cat as Type).Name);
            }

            return(cat.ToString());
        }
Exemplo n.º 2
0
        public static string ToShortNameString(this Enum cat)
        {
            var atrDisp = ReflexionUtils.GetAtribute <DisplayAttribute>(cat);

            if (atrDisp != null)
            {
                return(atrDisp.GetShortName());
            }

            return(cat.ToString());
        }
Exemplo n.º 3
0
        public static string ToDescriptionString(this Enum cat)
        {
            var atrDisp = ReflexionUtils.GetAtribute <DisplayAttribute>(cat);

            if (atrDisp != null)
            {
                return(atrDisp.GetDescription());
            }

            var atrDesc = GetAtribute <DescriptionAttribute>(cat);

            if (atrDesc != null)
            {
                return(atrDesc.Description);
            }

            return("-");
        }
Exemplo n.º 4
0
        public static string ToDisplayString(this Enum cat)
        {
            var atrDisp = ReflexionUtils.GetAtribute <DisplayAttribute>(cat);

            if (atrDisp != null)
            {
                return(atrDisp.GetName());
            }

            var atrDispName = GetAtribute <DisplayNameAttribute>(cat);

            if (atrDispName != null)
            {
                return(atrDispName.DisplayName);
            }

            return(cat.ToString());
        }