示例#1
0
        /// <summary>Save the configuration file for a content pack.</summary>
        /// <param name="contentPack">The content pack.</param>
        /// <param name="config">The configuration to save.</param>
        /// <param name="modHelper">The mod helper through which to save the file.</param>
        public void Save(IContentPack contentPack, InvariantDictionary <ConfigField> config, IModHelper modHelper)
        {
            // save if settings valid
            if (config.Any())
            {
                InvariantDictionary <string> data = new(config.ToDictionary(p => p.Key, p => string.Join(", ", p.Value.Value)));
                contentPack.WriteJsonFile(this.Filename, data);
            }

            // delete if no settings
            else
            {
                FileInfo file = new(Path.Combine(contentPack.GetFullPath(this.Filename)));
                if (file.Exists)
                {
                    file.Delete();
                }
            }
        }