using System;
using System.IO;
using Newtonsoft.Json;
namespace StardewModdingAPI.Advanced
{
/// Wraps a configuration file with IO methods for convenience.
[Obsolete]
public abstract class ConfigFile : IConfigFile
{
/*********
** Accessors
*********/
/// Provides simplified APIs for writing mods.
public IModHelper ModHelper { get; set; }
/// The file path from which the model was loaded, relative to the mod directory.
public string FilePath { get; set; }
/*********
** Public methods
*********/
/// Reparse the underlying file and update this model.
public void Reload()
{
string json = File.ReadAllText(Path.Combine(this.ModHelper.DirectoryPath, this.FilePath));
JsonConvert.PopulateObject(json, this);
}
/// Save this model to the underlying file.
public void Save()
{
this.ModHelper.WriteJsonFile(this.FilePath, this);
}
}
}