Beispiel #1
0
 public static string DisplayName <T>(Expression <Func <T, object> > ex)
 {
     return(Safe.Run(() => {
         var name = Name(ex);
         var p = GetClass.Property <T>(name);
         var list = p?.GetCustomAttributes(typeof(DisplayNameAttribute), true);
         if (list is null || list.Length < 1)
         {
             return name;
         }
         var a = list.Cast <DisplayNameAttribute>().Single();
         return a?.DisplayName ?? name;
     }, string.Empty));
 }
Beispiel #2
0
 private static void setValuesForProperties(object o)
 {
     if (o is null)
     {
         return;
     }
     foreach (var p in GetClass.Properties(o.GetType()))
     {
         if (!p.CanWrite)
         {
             return;
         }
         var v = GetRandom.Value(p.PropertyType);
         p.SetValue(o, v);
     }
 }