private void SetDependencies() { foreach (PlusModuleInfo module in _modules) { module.Dependencies.Clear(); foreach (Type dependedModuleType in PlusModule.FindDependedModuleTypes(module.Type)) { PlusModuleInfo PlusModuleInfo = _modules.FirstOrDefault((PlusModuleInfo m) => m.Type == dependedModuleType); if (PlusModuleInfo == null) { throw new PlusInitializationException("无法找到依赖的模块 " + dependedModuleType.AssemblyQualifiedName + " for " + module.Type.AssemblyQualifiedName); } if (module.Dependencies.FirstOrDefault((PlusModuleInfo dm) => dm.Type == dependedModuleType) == null) { module.Dependencies.Add(PlusModuleInfo); } } } }
private void CreateModules(ICollection <Type> moduleTypes) { foreach (var moduleType in moduleTypes) { if (!(_iocManager.Resolve(moduleType) is PlusModule moduleObject)) { throw new PlusInitializationException("从类型不是 Plus 模块: " + moduleType.AssemblyQualifiedName); } moduleObject.IocManager = _iocManager; moduleObject.Configuration = _iocManager.Resolve <IPlusStartupConfiguration>(); var moduleInfo = new PlusModuleInfo(moduleType, moduleObject); _modules.Add(moduleInfo); if (moduleType == _modules.StartupModuleType) { StartupModule = moduleInfo; } Logger.DebugFormat("加载模块: " + moduleType.AssemblyQualifiedName); } }