private void LoadAll() { Logger.Debug("开始加载模块"); var moduleTypes = AddMissingDependedModules(_moduleFinder.FindAll()); Logger.Debug("查找到 " + moduleTypes.Count + " 个模块"); //Register to IOC container. foreach (var moduleType in moduleTypes) { if (!Module.IsModule(moduleType)) { throw new Exception("此类型不是有效的模块: " + moduleType.AssemblyQualifiedName); } if (!_iocManager.IsRegistered(moduleType)) { _iocManager.Register(moduleType); } } //Add to module collection foreach (var moduleType in moduleTypes) { var moduleObject = (Module)_iocManager.Resolve(moduleType); moduleObject.IocManager = _iocManager; moduleObject.Configuration = _iocManager.Resolve <IStartupConfiguration>(); _modules.Add(new ModuleInfo(moduleObject)); Logger.Debug("已加载模块: " + moduleType.AssemblyQualifiedName); } EnsureKernelModuleToBeFirst(); SetDependencies(); Logger.Debug(string.Format("{0} modules loaded.", _modules.Count)); }
private void CreateModules(ICollection <Type> moduleTypes) { foreach (var moduleType in moduleTypes) { var moduleObject = _iocManager.Resolve(moduleType) as InfrastructureModule; if (moduleObject == null) { throw new InitializationException("This type is not an module: " + moduleType.AssemblyQualifiedName); } moduleObject.IocManager = _iocManager; moduleObject.Configuration = _iocManager.Resolve <IStartupConfiguration>(); var moduleInfo = new ModuleInfo(moduleType, moduleObject); _modules.Add(moduleInfo); if (moduleType == _modules.StartupModuleType) { StartupModule = moduleInfo; } Logger.DebugFormat("Loaded module: " + moduleType.AssemblyQualifiedName); } }