コード例 #1
0
ファイル: SettingsJson.cs プロジェクト: Yevrag35/ManagementUI
        //[OnDeserialized]
        //private void OnDeserialized(StreamingContext ctx)
        //{
        //    if (this.Settings != null && this.Settings.Apps != null)
        //    {
        //        this.Settings.Apps.CollectionChanged += this.Settings_Changed;
        //    }
        //}

        private void Save(JObject saveThis, SettingChangedAction action)
        {
            using (var streamWriter = new StreamWriter(this.FilePath))
            {
                using (var writer = new JsonTextWriter(streamWriter)
                {
                    AutoCompleteOnClose = true,
                    CloseOutput = true,
                    DateFormatHandling = DateFormatHandling.IsoDateFormat,
                    DateTimeZoneHandling = DateTimeZoneHandling.Utc,
                    Formatting = Formatting.Indented,
                    IndentChar = char.Parse("\t"),
                    Indentation = 1
                })
                {
                    saveThis.WriteTo(writer, new StringEnumConverter(new CamelCaseNamingStrategy()));
                    streamWriter.Flush();
                    streamWriter.Close();
                }
            }

            base.OnSettingsChanged(new SettingsChangedEventArgs(action));
        }
コード例 #2
0
 /// <summary>
 /// The default constructor specifying the action that took place.
 /// </summary>
 /// <param name="action">The specific action that triggered the event.</param>
 public SettingsChangedEventArgs(SettingChangedAction action) => this.Action = action;
コード例 #3
0
ファイル: SettingsJson.cs プロジェクト: Yevrag35/ManagementUI
        //private void Settings_Changed(object sender, NotifyCollectionChangedEventArgs e) => this.Save();

        public void Save(SettingChangedAction action = SettingChangedAction.Save)
        {
            this.Save(((IJsonSettings)this).SettingsAsJson, action);
        }