public static ABehaviourAccess <T> Create <T>(ModuleManagerConfig config, IModule module)
        {
            if (typeof(T) == typeof(ModuleStartBehaviour))
            {
                return(new StartBehaviorAccess(config, module) as ABehaviourAccess <T>);
            }

            if (typeof(T) == typeof(FailureBehaviour))
            {
                return(new FailureBehaviourAccess(config, module) as ABehaviourAccess <T>);
            }

            return(null);
        }
        /// <summary>
        /// Initialize the module manager.
        /// </summary>
        public void Initialize()
        {
            // Create components
            LoggerManagement.ActivateLogging(this);
            _config = ConfigManager.GetConfiguration <ModuleManagerConfig>();

            // Create dependency manager and build tree of available modules
            _dependencyManager = new ModuleDependencyManager(Logger.GetChild(string.Empty, typeof(ModuleDependencyManager)));
            var availableModules = _dependencyManager.BuildDependencyTree(ServerModules);

            // Create dedicated components for stopping and starting
            var waitingModules = new Dictionary <IServerModule, ICollection <IServerModule> >();

            _moduleStarter = new ModuleStarter(_dependencyManager, Logger.GetChild(string.Empty, typeof(ModuleStarter)), _config)
            {
                AvailableModules = availableModules,
                WaitingModules   = waitingModules
            };
            _moduleStopper = new ModuleStopper(_dependencyManager, Logger.GetChild(string.Empty, typeof(ModuleStopper)))
            {
                AvailableModules = availableModules,
                WaitingModules   = waitingModules
            };

            // Link framework modules
            foreach (var platformModule in availableModules.OfType <IPlatformModule>())
            {
                platformModule.SetModuleManager(this);
            }

            // Observe state changed events of modules
            foreach (var module in availableModules)
            {
                module.StateChanged += OnModuleStateChanged;
            }

            AllModules = ServerModules;
        }
 public FailureBehaviourAccess(ModuleManagerConfig config, IModule module) : base(config, module)
 {
 }
 public StartBehaviorAccess(ModuleManagerConfig config, IModule module) : base(config, module)
 {
 }
Esempio n. 5
0
 public ModuleStarter(IModuleDependencyManager dependencyManager, IModuleLogger logger, ModuleManagerConfig config)
 {
     _dependencyManager = dependencyManager;
     _logger            = logger;
     _config            = config;
 }