Esempio n. 1
0
 public static void Build()
 {
     if (builder != null)
     {
         container = builder.Build();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 开始执行框架初始化
        /// </summary>
        /// <param name="iocBuilder">依赖注入构建器</param>
        public void Initialize(IIocBuilder iocBuilder)
        {
            iocBuilder.CheckNotNull("iocBuilder");

            JceConfig config = JceConfig.Instance;

            //依赖注入初始化
            IServiceProvider provider = iocBuilder.Build();

            //对象映射功能初始化

            //日志功能初始化
            IBasicLoggingInitializer loggingInitializer = provider.GetService <IBasicLoggingInitializer>();

            if (!_basicLoggingInitialized && loggingInitializer != null)
            {
                loggingInitializer.Initialize(config.LoggingConfig);
                _basicLoggingInitialized = true;
            }

            //数据库初始化

            //实体信息初始化

            //功能信息初始化
        }
Esempio n. 3
0
        public static AppSetupBase RegisterAndGetAppSetup <TAppSetup>(this IIocBuilder builder, Action <IIocBuilder> registerAction = null) where TAppSetup : AppSetupBase
        {
            builder.RegisterSetup <TAppSetup>();
            registerAction?.Invoke(builder);
            var ioc = builder.Build();

            return(ioc.Resolve <AppSetupBase>());
        }
Esempio n. 4
0
        /// <summary>
        /// 开始执行框架初始化
        /// </summary>
        /// <param name="iocBuilder">依赖注入构建器</param>
        public void Initialize(IIocBuilder iocBuilder)
        {
            iocBuilder.CheckNotNull("iocBuilder");

            OSharpConfig config = OSharpConfig.Instance;

            //依赖注入初始化
            IServiceProvider provider = iocBuilder.Build();

            //对象映射功能初始化
            IMappersBuilder mappersBuilder = provider.GetService <IMappersBuilder>();
            IMapper         mapper         = provider.GetService <IMapper>();

            if (!_mapperInitialized && mapper != null)
            {
                if (mappersBuilder != null)
                {
                    IEnumerable <IMapTuple> mapTuples = provider.GetServices <IMapTuple>();
                    mappersBuilder.Build(mapTuples);
                }
                MapperExtensions.SetMaper(mapper);
                _mapperInitialized = true;
            }

            //日志功能初始化
            IBasicLoggingInitializer loggingInitializer = provider.GetService <IBasicLoggingInitializer>();

            if (!_basicLoggingInitialized && loggingInitializer != null)
            {
                loggingInitializer.Initialize(config.LoggingConfig);
                _basicLoggingInitialized = true;
            }

            //数据库初始化
            IDatabaseInitializer databaseInitializer = provider.GetService <IDatabaseInitializer>();

            if (!_databaseInitialized && databaseInitializer != null)
            {
                databaseInitializer.Initialize(config.DataConfig);
                _databaseInitialized = true;
            }

            //实体信息初始化
            IEntityInfoHandler entityInfoHandler = provider.GetService <IEntityInfoHandler>();

            if (!_entityInfoInitialized && entityInfoHandler != null)
            {
                entityInfoHandler.Initialize();
                _entityInfoInitialized = true;
            }
            //功能信息初始化
            IFunctionHandler functionHandler = provider.GetService <IFunctionHandler>();

            if (functionHandler != null)
            {
                functionHandler.Initialize();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 开始执行框架初始化
        /// </summary>
        /// <param name="services">服务映射集合</param>
        /// <param name="iocBuilder">依赖注入构建器</param>
        public void Initialize(IServiceCollection services, IIocBuilder iocBuilder)
        {
            services.CheckNotNull("services");
            iocBuilder.CheckNotNull("iocBuilder");

            OSharpConfig config = OSharpConfig.Instance;

            //使用副本进行初始化,防止不同平台间的相互污染
            IServiceCollection newServices = services.Clone();
            //依赖注入初始化
            IServiceProvider provider = iocBuilder.Build(newServices);

            //日志功能初始化
            IBasicLoggingInitializer loggingInitializer = provider.GetService <IBasicLoggingInitializer>();

            if (!_basicLoggingInitialized && loggingInitializer != null)
            {
                loggingInitializer.Initialize(config.LoggingConfig);
                _basicLoggingInitialized = true;
            }

            //数据库初始化
            IDatabaseInitializer databaseInitializer = provider.GetService <IDatabaseInitializer>();

            if (!_databaseInitialized)
            {
                if (databaseInitializer == null)
                {
                    throw new InvalidOperationException(Resources.FrameworkInitializerBase_DatabaseInitializeIsNull);
                }
                databaseInitializer.Initialize(config.DataConfig);
                _databaseInitialized = true;
            }

            //实体信息初始化
            if (!_entityInfoInitialized)
            {
                IEntityInfoHandler entityInfoHandler = provider.GetService <IEntityInfoHandler>();
                if (entityInfoHandler == null)
                {
                    throw new InvalidOperationException(Resources.FrameworkInitializerBase_EntityInfoHandlerIsNull);
                }
                entityInfoHandler.Initialize();
                _entityInfoInitialized = true;
            }
            //功能信息初始化
            IFunctionHandler functionHandler = provider.GetService <IFunctionHandler>();

            if (functionHandler == null)
            {
                throw new InvalidOperationException(Resources.FrameworkInitializerBase_FunctionHandlerIsNull);
            }
            functionHandler.Initialize();
        }
Esempio n. 6
0
        /// <summary>
        /// 开始执行框架初始化
        /// </summary>
        /// <param name="iocBuilder">依赖注入构建器</param>
        public void Initialize(IIocBuilder iocBuilder)
        {
            iocBuilder.CheckNotNull("iocBuilder");

            OSharpConfig config = OSharpConfig.Instance;

            //依赖注入初始化
            IServiceProvider provider = iocBuilder.Build();

            //对象映射功能初始化
            IMappersBuilder mappersBuilder = provider.GetService<IMappersBuilder>();
            IMapper mapper = provider.GetService<IMapper>();
            if (!_mapperInitialized && mapper != null)
            {
                if (mappersBuilder != null)
                {
                    IEnumerable<IMapTuple> mapTuples = provider.GetServices<IMapTuple>();
                    mappersBuilder.Build(mapTuples);
                }
                MapperExtensions.SetMaper(mapper);
                _mapperInitialized = true;
            }

            //日志功能初始化
            IBasicLoggingInitializer loggingInitializer = provider.GetService<IBasicLoggingInitializer>();
            if (!_basicLoggingInitialized && loggingInitializer != null)
            {
                loggingInitializer.Initialize(config.LoggingConfig);
                _basicLoggingInitialized = true;
            }

            //数据库初始化
            IDatabaseInitializer databaseInitializer = provider.GetService<IDatabaseInitializer>();
            if (!_databaseInitialized && databaseInitializer != null)
            {
                databaseInitializer.Initialize(config.DataConfig);
                _databaseInitialized = true;
            }

            //实体信息初始化
            IEntityInfoHandler entityInfoHandler = provider.GetService<IEntityInfoHandler>();
            if (!_entityInfoInitialized && entityInfoHandler != null)
            {
                entityInfoHandler.Initialize();
                _entityInfoInitialized = true;
            }
            //功能信息初始化
            IFunctionHandler functionHandler = provider.GetService<IFunctionHandler>();
            if (functionHandler != null)
            {
                functionHandler.Initialize();
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 开始执行框架初始化
        /// </summary>
        /// <param name="services">服务映射集合</param>
        /// <param name="iocBuilder">依赖注入构建器</param>
        public void Initialize(IServiceCollection services, IIocBuilder iocBuilder)
        {
            services.CheckNotNull("services");
            iocBuilder.CheckNotNull("iocBuilder");

            OSharpConfig config = OSharpConfig.Instance;

            //使用副本进行初始化,防止不同平台间的相互污染
            IServiceCollection newServices = services.Clone();
            //依赖注入初始化
            IServiceProvider provider = iocBuilder.Build(newServices);

            //日志功能初始化
            IBasicLoggingInitializer loggingInitializer = provider.GetService<IBasicLoggingInitializer>();
            if (!_basicLoggingInitialized && loggingInitializer != null)
            {
                loggingInitializer.Initialize(config.LoggingConfig);
                _basicLoggingInitialized = true;
            }

            //数据库初始化
            IDatabaseInitializer databaseInitializer = provider.GetService<IDatabaseInitializer>();
            if (!_databaseInitialized)
            {
                if (databaseInitializer == null)
                {
                    throw new InvalidOperationException(Resources.FrameworkInitializerBase_DatabaseInitializeIsNull);
                }
                databaseInitializer.Initialize(config.DataConfig);
                _databaseInitialized = true;
            }

            //实体信息初始化
            if (!_entityInfoInitialized)
            {
                IEntityInfoHandler entityInfoHandler = provider.GetService<IEntityInfoHandler>();
                if (entityInfoHandler == null)
                {
                    throw new InvalidOperationException(Resources.FrameworkInitializerBase_EntityInfoHandlerIsNull);
                }
                entityInfoHandler.Initialize();
                _entityInfoInitialized = true;
            }
            //功能信息初始化
            IFunctionHandler functionHandler = provider.GetService<IFunctionHandler>();
            if (functionHandler == null)
            {
                throw new InvalidOperationException(Resources.FrameworkInitializerBase_FunctionHandlerIsNull);
            }
            functionHandler.Initialize();
        }
Esempio n. 8
0
        /// <summary>
        /// 开始执行框架初始化
        /// </summary>
        /// <param name="iocBuilder">依赖注入构建器</param>
        public void Initialize(IIocBuilder iocBuilder)
        {
            iocBuilder.CheckNotNull("iocBuilder");

            TomNetConfig config = TomNetConfig.Instance;

            //依赖注入初始化
            IServiceProvider provider = iocBuilder.Build();

            //日志功能初始化
            IBasicLoggingInitializer loggingInitializer = provider.GetService <IBasicLoggingInitializer>();

            if (!_basicLoggingInitialized && loggingInitializer != null)
            {
                loggingInitializer.Initialize(config.LoggingConfig);
                _basicLoggingInitialized = true;
            }

            //数据库初始化
            IDatabaseInitializer databaseInitializer = provider.GetService <IDatabaseInitializer>();

            if (!_databaseInitialized && databaseInitializer != null)
            {
                databaseInitializer.Initialize(config.DataConfig);
                _databaseInitialized = true;
            }


            //功能信息初始化
            IFunctionHandler functionHandler = provider.GetService <IFunctionHandler>();

            if (functionHandler != null)
            {
                functionHandler.Initialize();
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 开始执行框架初始化
        /// </summary>
        /// <param name="iocBuilder">依赖注入构建器</param>
        public void Initialize(IIocBuilder iocBuilder)
        {
            iocBuilder.CheckNotNull("iocBuilder");

            OSharpConfig config = OSharpConfig.Instance;
            
            //依赖注入初始化
            IServiceProvider provider = iocBuilder.Build();

            //对象映射功能初始化
            IMappersBuilder mappersBuilder = provider.GetService<IMappersBuilder>();
            IMapper mapper = provider.GetService<IMapper>();
            if (!_mapperInitialized)
            {
                if (mappersBuilder != null)
                {
                    IEnumerable<IMapTuple> mapTuples = provider.GetServices<IMapTuple>();
                    mappersBuilder.Build(mapTuples);
                }
                if (mapper != null)
                {
                    MapperExtensions.SetMaper(mapper);
                }
                _mapperInitialized = true;
            }

            //日志功能初始化
            IBasicLoggingInitializer loggingInitializer = provider.GetService<IBasicLoggingInitializer>();
            if (!_basicLoggingInitialized && loggingInitializer != null)
            {
                loggingInitializer.Initialize(config.LoggingConfig);
                _basicLoggingInitialized = true;
            }

            //数据库初始化
            IDatabaseInitializer databaseInitializer = provider.GetService<IDatabaseInitializer>();
            if (!_databaseInitialized)
            {
                if (databaseInitializer == null)
                {
                    throw new InvalidOperationException(Resources.FrameworkInitializer_DatabaseInitializeIsNull);
                }
                databaseInitializer.Initialize(config.DataConfig);
                _databaseInitialized = true;
            }

            //实体信息初始化
            if (!_entityInfoInitialized)
            {
                IEntityInfoHandler entityInfoHandler = provider.GetService<IEntityInfoHandler>();
                if (entityInfoHandler == null)
                {
                    throw new InvalidOperationException(Resources.FrameworkInitializer_EntityInfoHandlerIsNull);
                }
                entityInfoHandler.Initialize();
                _entityInfoInitialized = true;
            }
            //功能信息初始化
            IFunctionHandler functionHandler = provider.GetService<IFunctionHandler>();
            if (functionHandler == null)
            {
                throw new InvalidOperationException(Resources.FrameworkInitializer_FunctionHandlerIsNull);
            }
            functionHandler.Initialize();
        }
Esempio n. 10
0
        /// <summary>
        /// 开始执行框架初始化
        /// </summary>
        /// <param name="iocBuilder">依赖注入构建器</param>
        public void Initialize(IIocBuilder iocBuilder)
        {
            iocBuilder.CheckNotNull("iocBuilder");

            OSharpConfig config = OSharpConfig.Instance;

            //依赖注入初始化
            IServiceProvider provider = iocBuilder.Build();

            //对象映射功能初始化
            IMappersBuilder mappersBuilder = provider.GetService <IMappersBuilder>();
            IMapper         mapper         = provider.GetService <IMapper>();

            if (!_mapperInitialized)
            {
                if (mappersBuilder != null)
                {
                    IEnumerable <IMapTuple> mapTuples = provider.GetServices <IMapTuple>();
                    mappersBuilder.Build(mapTuples);
                }
                if (mapper != null)
                {
                    MapperExtensions.SetMaper(mapper);
                }
                _mapperInitialized = true;
            }

            //日志功能初始化
            IBasicLoggingInitializer loggingInitializer = provider.GetService <IBasicLoggingInitializer>();

            if (!_basicLoggingInitialized && loggingInitializer != null)
            {
                loggingInitializer.Initialize(config.LoggingConfig);
                _basicLoggingInitialized = true;
            }

            //数据库初始化
            IDatabaseInitializer databaseInitializer = provider.GetService <IDatabaseInitializer>();

            if (!_databaseInitialized)
            {
                if (databaseInitializer == null)
                {
                    throw new InvalidOperationException(Resources.FrameworkInitializer_DatabaseInitializeIsNull);
                }
                databaseInitializer.Initialize(config.DataConfig);
                _databaseInitialized = true;
            }

            //实体信息初始化
            if (!_entityInfoInitialized)
            {
                IEntityInfoHandler entityInfoHandler = provider.GetService <IEntityInfoHandler>();
                if (entityInfoHandler == null)
                {
                    throw new InvalidOperationException(Resources.FrameworkInitializer_EntityInfoHandlerIsNull);
                }
                entityInfoHandler.Initialize();
                _entityInfoInitialized = true;
            }
            //功能信息初始化
            IFunctionHandler functionHandler = provider.GetService <IFunctionHandler>();

            if (functionHandler == null)
            {
                throw new InvalidOperationException(Resources.FrameworkInitializer_FunctionHandlerIsNull);
            }
            functionHandler.Initialize();
        }