Esempio n. 1
0
        public static Config ParseConfig(string configFile)
        {
            string[] configLines = Regex.Split(configFile, "\r\n|\r|\n");

            if (!configLines[0].StartsWith("["))
            {
                throw new ArgumentException("Config file did not start with a config header");
            }

            int discordHeaderIndex = configLines.ToList().FindIndex(x => (x == "[Discord]"));
            int twitchHeaderIndex  = configLines.ToList().FindIndex(x => (x == "[Twitch]"));

            if (discordHeaderIndex < 0 && twitchHeaderIndex < 0)
            {
                throw new ArgumentException("Config file does not contain any valid config headers");
            }

            DiscordConfig discord = null;
            TwitchConfig  twitch  = null;

            if (discordHeaderIndex >= 0)
            {
                discord = GetDiscordConfig(configLines, discordHeaderIndex);
            }

            if (twitchHeaderIndex >= 0)
            {
                twitch = GetTwitchConfig(configLines, twitchHeaderIndex);
            }

            return(new Config(twitch, discord));
        }
Esempio n. 2
0
 public Config(TwitchConfig twitch, DiscordConfig discord)
 {
     Twitch  = twitch;
     Discord = discord;
 }