Esempio n. 1
0
 public static bool HasDefaultConstructor(Type t, bool nonPublic)
 {
     ValidationUtils.ArgumentNotNull(t, "t");
     if (t.IsValueType())
     {
         return(true);
     }
     return(ReflectionUtils.GetDefaultConstructor(t, nonPublic) != null);
 }
        public override Func <T> CreateDefaultConstructor <T>(Type type)
        {
            ValidationUtils.ArgumentNotNull(type, "type");
            if (type.IsValueType)
            {
                return(() => (T)((object)ReflectionUtils.CreateInstance(type, new object[0])));
            }
            ConstructorInfo constructorInfo = ReflectionUtils.GetDefaultConstructor(type, true);

            return(() => (T)((object)constructorInfo.Invoke(null)));
        }
        public override Func <T> CreateDefaultConstructor <T>(Type type)
        {
            ValidationUtils.ArgumentNotNull(type, "type");
            if (type.IsValueType())
            {
                return(() => (T)Activator.CreateInstance(type));
            }
            ConstructorInfo defaultConstructor = ReflectionUtils.GetDefaultConstructor(type, true);

            return(() => (T)defaultConstructor.Invoke(null));
        }
Esempio n. 4
0
        public override Func <T> CreateDefaultConstructor <T>(Type type)
        {
            ValidationUtils.ArgumentNotNull((object)type, nameof(type));
            if (type.IsValueType())
            {
                return((Func <T>)(() => (T)Activator.CreateInstance(type)));
            }
            ConstructorInfo constructorInfo = ReflectionUtils.GetDefaultConstructor(type, true);

            return((Func <T>)(() => (T)constructorInfo.Invoke((object[])null)));
        }
Esempio n. 5
0
        public override Func <T> CreateDefaultConstructor <T>(Type type)
        {
            if (type.IsValueType)
            {
                return(() => (T)ReflectionUtils.CreateInstance(type));
            }

            ConstructorInfo constructorInfo = ReflectionUtils.GetDefaultConstructor(type, true);

            return(() => (T)constructorInfo.Invoke(null));
        }
Esempio n. 6
0
        public override Func <T> CreateDefaultConstructor <T>(Type type)
        {
            ConstructorInfo constructorInfo;

            ValidationUtils.ArgumentNotNull(type, "type");
            if (!type.IsValueType())
            {
                constructorInfo = ReflectionUtils.GetDefaultConstructor(type, true);
            }
            return(() => ((T)constructorInfo.Invoke(null)));
        }
Esempio n. 7
0
 public static bool HasDefaultConstructor(Type t, bool nonPublic)
 {
     ValidationUtils.ArgumentNotNull((object)t, "t");
     if (TypeExtensions.IsValueType(t))
     {
         return(true);
     }
     else
     {
         return(ReflectionUtils.GetDefaultConstructor(t, nonPublic) != null);
     }
 }
Esempio n. 8
0
        public override Newtonsoft.Json.Serialization.Func <T> CreateDefaultConstructor <T>(Type type)
        {
            ValidationUtils.ArgumentNotNull(type, nameof(type));

            if (type.IsValueType())
            {
                return(() => (T)Activator.CreateInstance(type));
            }

            ConstructorInfo constructorInfo = ReflectionUtils.GetDefaultConstructor(type, true);

            return(() => (T)constructorInfo.Invoke(null));
        }
Esempio n. 9
0
 // Token: 0x06000E22 RID: 3618 RVA: 0x00051A74 File Offset: 0x0004FC74
 public static ConstructorInfo GetDefaultConstructor(Type t)
 {
     return(ReflectionUtils.GetDefaultConstructor(t, false));
 }
Esempio n. 10
0
 public static bool HasDefaultConstructor(Type t, bool nonPublic)
 {
     ValidationUtils.ArgumentNotNull((object)t, nameof(t));
     return(t.IsValueType() || ReflectionUtils.GetDefaultConstructor(t, nonPublic) != null);
 }