コード例 #1
0
        public void Start()
        {
            SpeedDateConfig.Initialize(_configFile);
            var logger = LogManager.GetLogger("SpeedDate");
            var kernel = CreateKernel();

            var startable = kernel.Get <ISpeedDateStartable>();

            startable.Started += () => Started?.Invoke();
            startable.Stopped += () => Stopped?.Invoke();

            PluginProver = kernel.Get <IPluginProvider>();

            foreach (var plugin in kernel.GetAll <IPlugin>())
            {
                PluginProver.RegisterPlugin(plugin);
            }

            foreach (var plugin in PluginProver.GetAll())
            {
                plugin.Loaded(PluginProver);
                logger.Info($"Loaded {plugin.GetType().Name}");
            }

            var server = kernel.TryGet <IServer>();

            if (server != null)
            {
                logger.Info("Acting as server: " + server.GetType().Name);
            }

            var client = kernel.TryGet <IClient>();

            if (client != null)
            {
                logger.Info("Acting as client: " + client.GetType().Name);
            }

            startable.Start();
        }