コード例 #1
0
ファイル: ConstructorSupport.cs プロジェクト: pondyond/db4o
        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));
        }
コード例 #2
0
ファイル: ConstructorSupport.cs プロジェクト: masroore/db4o
 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);
 }