Esempio n. 1
0
 internal static string DefaultMemberDescription(MemberInfo m)
 {
     return m.SingleAttribute<DescriptionAttribute>().Try(t => t.Description) ?? m.Name.NiceName();
 }
Esempio n. 2
0
        static LambdaExpression GetExpansion(MemberInfo mi)
        {
            ExpressionFieldAttribute efa = mi.SingleAttribute<ExpressionFieldAttribute>();

            string name = efa.Try(a => a.Name) ?? mi.Name + "Expression";
            Type type = mi.DeclaringType;

            FieldInfo fi = type.GetField(name, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
            if (fi != null)
                return fi.GetValue(null) as LambdaExpression;
            else if (efa != null)
                throw new InvalidOperationException("Expression field '{0}' not found on '{1}'".Formato(name, type.TypeName())); 

            return null;
        }
Esempio n. 3
0
        static string GetMemberNiceName(MemberInfo memberInfo)
        {
            var cc = CultureInfo.CurrentUICulture;
            var type = memberInfo.DeclaringType;

            if (LocalizedAssembly.GetDefaultAssemblyCulture(type.Assembly) == null)
            {
                if (type == typeof(DayOfWeek))
                    return CultureInfo.CurrentCulture.DateTimeFormat.DayNames[(int)((FieldInfo)memberInfo).GetValue(null)];

                return memberInfo.SingleAttribute<DescriptionAttribute>().Try(a => a.Description) ?? memberInfo.Name.NiceName();
            }
       
            var result = Fallback(type, lt => lt.Members.TryGetC(memberInfo.Name));
            if (result != null)
                return result;

            return result;
        }