示例#1
0
文件: Core.cs 项目: ngs-doo/revenj
        public static IServiceProvider Setup(
            Revenj.Extensibility.Setup.IContainerBuilder builder,
            bool withAspects,
            bool externalConfiguration,
            params Action<IObjectFactoryBuilder>[] setupExternal)
        {
            var state = new SystemState();
            builder.RegisterSingleton<ISystemState>(state);
            foreach (var se in setupExternal)
                se(builder);
            var serverModels =
                (from asm in Revenj.Utility.AssemblyScanner.GetAssemblies()
                 let type = asm.GetType("SystemBoot.Configuration")
                 where type != null && type.GetMethod("Initialize") != null
                 select asm)
                .ToList();
            builder.ConfigurePatterns(_ => serverModels);
            builder.ConfigureSerialization();
            builder.ConfigureSecurity(false);
            builder.RegisterFunc<IEnumerable<Assembly>>(f => AssemblyScanner.GetAssemblies());
            builder.RegisterFunc<IEnumerable<Type>>(f => AssemblyScanner.GetAllTypes());

            var factory = builder.Build();
            factory.Resolve<IDomainModel>();//TODO: explicit model initialization
            state.IsBooting = false;
            state.Started(factory);
            return factory;
        }