Example #1
0
        public static string DisplayName <TRet>(Expression <Func <TModel, TRet> > expression)
        {
            var exp = expression.Body as MemberExpression;

            if (exp is null)
            {
                throw new NotSupportedException("This argument 'expression' must be MemberExpression.");
            }

            return(DataAnnotationEx.GetDisplayName(exp.Member));
        }
Example #2
0
        public static string DisplayName(this Enum @this)
        {
            var field = @this.GetType().GetFields().First(x => x.Name == @this.ToString());

            return(DataAnnotationEx.GetDisplayName(field));
        }