Exemplo n.º 1
0
        public static CactbotEventSourceConfig LoadConfig(IPluginConfig pluginConfig, RainbowMage.OverlayPlugin.ILogger logger)
        {
            var result = new CactbotEventSourceConfig();

            if (pluginConfig.EventSourceConfigs.ContainsKey("CactbotESConfig"))
            {
                var obj = pluginConfig.EventSourceConfigs["CactbotESConfig"];

                if (obj.TryGetValue("OverlayData", out JToken value))
                {
                    try {
                        result.OverlayData = value.ToObject <Dictionary <string, JToken> >();
                    } catch (Exception e) {
                        logger.Log(LogLevel.Error, Strings.LoadOverlayDataSettingsFailed, e.ToString());
                    }
                }

                if (obj.TryGetValue("LastUpdateCheck", out value))
                {
                    try {
                        result.LastUpdateCheck = value.ToObject <DateTime>();
                    } catch (Exception e) {
                        logger.Log(LogLevel.Error, Strings.LoadLastUpdateCheckSettingsFailed, e.ToString());
                    }
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public static CactbotEventSourceConfig LoadConfig(IPluginConfig pluginConfig, RainbowMage.OverlayPlugin.ILogger logger)
        {
            var result = new CactbotEventSourceConfig();

            if (pluginConfig.EventSourceConfigs.ContainsKey("CactbotESConfig"))
            {
                var obj = pluginConfig.EventSourceConfigs["CactbotESConfig"];

                // TODO: add try/catch here
                if (obj.TryGetValue("OverlayData", out JToken value))
                {
                    try {
                        result.OverlayData = value.ToObject <Dictionary <string, JToken> >();
                    } catch (Exception e) {
                        logger.Log(LogLevel.Error, "Failed to load OverlayData setting: {0}", e.ToString());
                    }
                }

                if (obj.TryGetValue("RemoteVersionSeen", out value))
                {
                    result.RemoteVersionSeen = value.ToString();
                }
            }

            return(result);
        }