예제 #1
0
        public AppSettingsModel Load()
        {
            AppSettingsModel model;

            try
            {
                string json = File.ReadAllText(FileSettings);
                model = JsonSerializer.Deserialize <AppSettingsModel>(json);
            }
            catch
            {
                model = new AppSettingsModel();
            }

            //inicialize values
            if (model.MainAccount == null)
            {
                model.MainAccount = new MainAccount();
            }
            if (model.NotificationAccount == null)
            {
                model.NotificationAccount = new NotificationAccountSettings();
            }
            if (model.ReaderSettings == null)
            {
                model.ReaderSettings = new ReaderSettings();
            }
            if (model.SenderSettings == null)
            {
                model.SenderSettings = new SenderSettings();
            }
            if (model.LetterTemplate == null)
            {
                model.LetterTemplate = new Letter();
            }
            return(model);
        }
예제 #2
0
        public void Save(AppSettingsModel appSettings)
        {
            string json = JsonSerializer.Serialize <AppSettingsModel>(appSettings);

            File.WriteAllText(FileSettings, json);
        }