예제 #1
0
        /// <summary>
        /// The get instance.
        /// </summary>
        /// <param name="logger">
        /// The logger.
        /// </param>
        /// <returns>
        /// The <see cref="WinFormGlobalContext"/>.
        /// </returns>
        /// <exception cref="ArgumentException">
        /// </exception>
        internal static WinFormGlobalContext GetInstance(ILogger logger)
        {
            if (logger == null)
            {
                throw new ArgumentException("Logger cannot be null for Global Context instance");
            }

            if (_instance == null)
            {
                _instance = new WinFormGlobalContext(logger);
            }
            else
            {
                _instance._logger = logger;
            }

            return _instance;
        }
예제 #2
0
        /// <summary>
        /// The get environment.
        /// </summary>
        /// <param name="executionParam">
        /// The execution param.
        /// </param>
        /// <param name="globalContext">
        /// The global context.
        /// </param>
        /// <returns>
        /// The <see cref="MonitorEnvironment"/>.
        /// </returns>
        private MonitorEnvironment GetEnvironment(ExecutionParam executionParam, WinFormGlobalContext globalContext)
        {
            var pluginResolver = new AssemblyPluginResolver(this.Logger);
            pluginResolver.LoadPlugins();
            var configStore = new FileConfigStore(AppUtil.GetLocalDataPath(this.ENV_CONFIG_FILENAME), pluginResolver, this.Logger);

            MonitorEnvironment env = configStore.LoadEnv();

            if (env == null || env.ArchiveManager == null || env.FareDatabase == null || env.FareDataProvider == null)
            {
                env = new MonitorEnvironment(configStore, pluginResolver, new BackgroundServiceManager(this.Logger), this.Logger);
                globalContext.AddServices(env);
                using (var configDialog = new EnvConfiguratorDialog(env, executionParam))
                {
                    if (configDialog.ShowDialog() == DialogResult.OK)
                    {
                        env = configDialog.ResultEnvironment;
                    }
                    else
                    {
                        env.Close();
                        env = null;
                    }
                }
            }

            return env;
        }