Esempio n. 1
0
        private void SaveConfig()
        {
            string exeLocation = AppDomain.CurrentDomain.BaseDirectory;
            string path        = Path.Combine(exeLocation, CONFIG_PATH);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string fileName = Path.Combine(exeLocation, CONFIG_PATH, RULES_FILENAME);

            string json = HttpRulesConvert.getJson(_httpRules);

            File.WriteAllText(fileName, json);
        }
Esempio n. 2
0
        private void LoadConfig()
        {
            string exeLocation = AppDomain.CurrentDomain.BaseDirectory;
            string path        = Path.Combine(exeLocation, CONFIG_PATH);

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            string fileName = Path.Combine(exeLocation, CONFIG_PATH, RULES_FILENAME);

            if (File.Exists(fileName))
            {
                string json = File.ReadAllText(fileName);
                _httpRules = HttpRulesConvert.getHttpRules(json);
            }
            else
            {
                _httpRules = new List <HttpRule>();
                string json = HttpRulesConvert.getJson(_httpRules);
                File.WriteAllText(fileName, json);
            }
        }