Beispiel #1
0
        /// <summary>
        /// InitCreateModules
        /// </summary>
        public void InitCreateModules(Type startupModule)
        {
            var builder     = new ContainerBuilder();
            var moduleTypes = new List <Type> {
                startupModule
            };

            moduleTypes.AddRange(FindDependedModuleTypes(startupModule));
            moduleTypes.Reverse();
            foreach (var moduleType in moduleTypes)
            {
                if (!IocManager.IocContainer.IsRegistered(moduleType))
                {
                    builder.RegisterType(moduleType).Named($"{moduleType}", typeof(WorkDataBaseModule))
                    .PropertiesAutowired();
                }
            }
            //update container
            _iocManager.UpdateContainer(builder);
        }
Beispiel #2
0
        /// <summary>
        ///     初始化Module(Register Module)
        /// </summary>
        /// <param name="startupModule"></param>
        public void InitModules(Type startupModule)
        {
            var builder     = new ContainerBuilder();
            var moduleTypes = new List <Type> {
                startupModule
            };                                                            //把自身加入进去

            moduleTypes.AddRange(FindDependedModuleTypes(startupModule)); //把startupModule依赖的项加入进去
            moduleTypes.Reverse();                                        //倒序,让自身最后注册
            //循环注册
            foreach (var moduleType in moduleTypes)
            {
                //避免重复注册
                if (!IocManager.Container.IsRegistered(moduleType))
                {
                    builder.RegisterType(moduleType)
                    .Named($"{moduleType}", typeof(AprilBaseModule))
                    .PropertiesAutowired();
                }
            }

            //更新Container
            _iocManager.UpdateContainer(builder);
        }