public HotKeyManager Initialize(ConfigurationServiceBase cfgSvc, IKeyboardHookService kbHookSvc)
        {
            _cfgSvc    = cfgSvc;
            _kbHookSvc = kbHookSvc;

            if (_cfgSvc == null)
            {
                throw new InvalidOperationException($"_cfgSvc cannot be null during {nameof(HotKeyManager)} initialization");
            }

            if (_config != null)
            {
                throw new InvalidOperationException($"{nameof(HotKeyManager)} is already initialized");
            }

            _config = _cfgSvc.Load <HotKeyCfg>().Result ?? new HotKeyCfg();

            foreach (var kvp in _config.HotKeyMap)
            {
                if (_userHotKeyMap.Reverse.ContainsKey(kvp.Value) == false)
                {
                    _userHotKeyMap[kvp.Key] = kvp.Value;
                }
            }

            return(this);
        }
Exemple #2
0
        public static LoggerCfg LoadConfig(ConfigurationServiceBase sharedConfig)
        {
            try
            {
                return(sharedConfig.Load <LoggerCfg>().Result ?? new LoggerCfg());
            }
            catch (Exception ex)
            {
                LogTo.Error(ex, "Exception while loading logger config");

                return(new LoggerCfg());
            }
        }
Exemple #3
0
        internal async Task ReloadConfigFromFile(ConfigurationServiceBase cfgService)
        {
            Config = await cfgService.Load <LoggerCfg>();

            ReloadConfig();
        }