Beispiel #1
0
        /// <summary>
        /// Saves the current fields and properties of the <see cref="JsonFile"/> as JSON properties to the file on disk.
        /// </summary>
        /// <seealso cref="Load(bool)"/>
        /// <seealso cref="SaveWithConverters(JsonConverter[])"/>
        public virtual void Save()
        {
            var e = new JsonFileEventArgs(this);

            OnStartedSaving?.Invoke(this, e);
            this.SaveJson(JsonFilePath, AlwaysIncludedJsonConverters.Distinct().ToArray());
            OnFinishedSaving?.Invoke(this, e);
        }
Beispiel #2
0
        /// <summary>
        /// Loads the JSON properties from the file on disk into the <see cref="JsonFile"/>.
        /// </summary>
        /// <param name="createFileIfNotExist">Whether a new JSON file should be created with default values if it does not
        /// already exist.</param>
        /// <seealso cref="Save()"/>
        /// <seealso cref="LoadWithConverters(bool, JsonConverter[])"/>
        public virtual void Load(bool createFileIfNotExist = true)
        {
            var e = new JsonFileEventArgs(this);

            OnStartedLoading?.Invoke(this, e);
            this.LoadJson(JsonFilePath, createFileIfNotExist, AlwaysIncludedJsonConverters.Distinct().ToArray());
            OnFinishedLoading?.Invoke(this, e);
        }