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

            OnStartedSaving?.Invoke(this, e);
            this.SaveJson(JsonFilePath, AlwaysIncludedJsonConverters.Distinct().ToArray());
            OnFinishedSaving?.Invoke(this, e);
        }
コード例 #2
0
        /// <summary>
        /// Loads the JSON properties from the file on disk into the <see cref="ConfigFile"/>.
        /// </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 void Load(bool createFileIfNotExist = true)
        {
            var e = new ConfigFileEventArgs(this);

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