Beispiel #1
0
 private static object UseType <T>(T instance)
 {
     if (typeof(T).IsValueType || typeof(T) == typeof(string))
     {
         return(instance);
     }
     if (instance is IEnumerable e)
     {
         var elType = EnumerableUtils.FirstOrDefault(e);
         if (elType?.GetType().GetTypeWithGenericTypeDefinitionOf(typeof(KeyValuePair <,>)) != null)
         {
             return(instance.ToObjectDictionary());
         }
         return(new List <object>(e.Cast <object>()));
     }
     return(instance.ToObjectDictionary());
 }
Beispiel #2
0
 public static bool IsEmpty(IEnumerable items) => EnumerableUtils.NullIfEmpty(items) == null;