Esempio n. 1
0
        private void CreateModules(IocBuilder iocBuilder, IStartupService startupConfiguration, ICollection <Type> moduleTypes)
        {
            foreach (var moduleType in moduleTypes)
            {
                var moduleObject = Activator.CreateInstance(moduleType) as JulyModule;
                if (moduleObject == null)
                {
                    throw new InvalidOperationException("This type is not a July Module: " + moduleType.AssemblyQualifiedName);
                }

                moduleObject.StartupService = startupConfiguration;

                var moduleInfo = new JulyModuleInfo(moduleType);
                moduleInfo.Instance = moduleObject;

                _moduleList.Add(moduleInfo);

                if (moduleType == _moduleList.StartupModuleType)
                {
                    StartupModule = moduleInfo;
                }

                iocBuilder.RegisterInstance(moduleObject).AsSelf().SingleInstance();

                Logger.LogDebug("Create module instance: " + moduleType.AssemblyQualifiedName);
            }
        }
Esempio n. 2
0
        public void Initialize(IocBuilder iocBuilder, IStartupService startupConfiguration)
        {
            iocBuilder.RegisterInstance(this).AsSelf().SingleInstance();

            Logger = startupConfiguration.LoggerFactory.CreateLogger <JulyModuleManager>();

            _moduleList = new JulyModuleCollection(StartupModuleType);

            LoadAllModules(iocBuilder, startupConfiguration);

            var sortedModules = _moduleList.GetSortedModuleListByDependency();

            foreach (var module in sortedModules)
            {
                module.Instance.Initialize();
                Logger.LogDebug($"Module: {module.Type.AssemblyQualifiedName} initialized");
            }
        }