Example #1
0
        public static IReflectConstructor SkipConstructor(IConstructorAwareReflectClass claxx
                                                          , bool skipConstructor, bool testConstructor)
        {
            if (!skipConstructor)
            {
                return(null);
            }
            var serializableConstructor = claxx.GetSerializableConstructor();

            if (serializableConstructor == null)
            {
                return(null);
            }
            if (!testConstructor || Deploy.csharp)
            {
                return(serializableConstructor);
            }
            var obj = serializableConstructor.NewInstance(null);

            if (obj != null)
            {
                return(serializableConstructor);
            }
            return(null);
        }
Example #2
0
        public static ReflectConstructorSpec CreateConstructor(IConstructorAwareReflectClass
                                                               claxx, Type clazz, IReflectorConfiguration config, IReflectConstructor[] constructors
                                                               )
        {
            if (claxx == null)
            {
                return(ReflectConstructorSpec.InvalidConstructor);
            }
            if (claxx.IsAbstract() || claxx.IsInterface())
            {
                return(ReflectConstructorSpec.InvalidConstructor);
            }
            if (!Platform4.CallConstructor())
            {
                var skipConstructor = !config.CallConstructor(claxx);
                if (!claxx.IsCollection())
                {
                    var serializableConstructor = SkipConstructor(claxx, skipConstructor
                                                                  , config.TestConstructors());
                    if (serializableConstructor != null)
                    {
                        return(new ReflectConstructorSpec(serializableConstructor, null));
                    }
                }
            }
            if (!config.TestConstructors())
            {
                return(new ReflectConstructorSpec(new PlatformReflectConstructor(clazz), null));
            }
            if (ReflectPlatform.CreateInstance(clazz) != null)
            {
                return(new ReflectConstructorSpec(new PlatformReflectConstructor(clazz), null));
            }
            var sortedConstructors = SortConstructorsByParamsCount(constructors);

            return(FindConstructor(claxx, sortedConstructors));
        }
Example #3
0
 public static ReflectConstructorSpec CreateConstructor(IConstructorAwareReflectClass
     claxx, Type clazz, IReflectorConfiguration config, IReflectConstructor[] constructors
     )
 {
     if (claxx == null)
     {
         return ReflectConstructorSpec.InvalidConstructor;
     }
     if (claxx.IsAbstract() || claxx.IsInterface())
     {
         return ReflectConstructorSpec.InvalidConstructor;
     }
     if (!Platform4.CallConstructor())
     {
         var skipConstructor = !config.CallConstructor(claxx);
         if (!claxx.IsCollection())
         {
             var serializableConstructor = SkipConstructor(claxx, skipConstructor
                 , config.TestConstructors());
             if (serializableConstructor != null)
             {
                 return new ReflectConstructorSpec(serializableConstructor, null);
             }
         }
     }
     if (!config.TestConstructors())
     {
         return new ReflectConstructorSpec(new PlatformReflectConstructor(clazz), null);
     }
     if (ReflectPlatform.CreateInstance(clazz) != null)
     {
         return new ReflectConstructorSpec(new PlatformReflectConstructor(clazz), null);
     }
     var sortedConstructors = SortConstructorsByParamsCount(constructors);
     return FindConstructor(claxx, sortedConstructors);
 }
Example #4
0
 public static IReflectConstructor SkipConstructor(IConstructorAwareReflectClass claxx
     , bool skipConstructor, bool testConstructor)
 {
     if (!skipConstructor)
     {
         return null;
     }
     var serializableConstructor = claxx.GetSerializableConstructor();
     if (serializableConstructor == null)
     {
         return null;
     }
     if (!testConstructor || Deploy.csharp)
     {
         return serializableConstructor;
     }
     var obj = serializableConstructor.NewInstance(null);
     if (obj != null)
     {
         return serializableConstructor;
     }
     return null;
 }