Пример #1
0
        private void showNewSiteForm(Settings s, int index)
        {
            FormSettings f = new FormSettings(index);
            if (f.ShowDialog() == DialogResult.OK)
            {
                s.SiteAddress[index] = f.SiteAddress;
                s.Providers[index] = f.ConnectionProvider;
                s.ConnectionStrings[index] = f.ConnectingString;
                s.Emails[index] = f.Email;
                s.Passwords[index] = f.Password;
                s.Save();

                showSiteForm(index);
            }
        }
Пример #2
0
        public static Settings Load()
        {
            string jsonPath = getJsonPath();
            if (!File.Exists(jsonPath))
            {
                Settings sts = new Settings();
                sts.ConnectionStrings = new Dictionary<int, string> { };
                sts.Providers = new Dictionary<int, DatabaseProvider> { };
                sts.SiteAddress = new Dictionary<int, string> { };
                sts.Emails = new Dictionary<int, string> { };
                sts.Passwords = new Dictionary<int, string> { };
                sts.Feed = new Dictionary<int, string> { };

                string json = JsonConvert.SerializeObject(sts, Formatting.Indented);
                File.WriteAllText(jsonPath, json, Encoding.UTF8);
            }

            return JsonConvert.DeserializeObject<Settings>(File.ReadAllText(jsonPath, Encoding.UTF8));
        }