using System;
namespace StardewModdingAPI
{
/// Provides an API for reading and storing local mod data.
public interface IDataHelper
{
/*********
** Public methods
*********/
/****
** JSON file
****/
/// Read data from a JSON file in the mod's folder.
/// The model type. This should be a plain class that has public properties for the data you want. The properties can be complex types.
/// The file path relative to the mod folder.
/// Returns the deserialized model, or null if the file doesn't exist or is empty.
/// The is not relative or contains directory climbing (../).
TModel ReadJsonFile(string path) where TModel : class;
/// Save data to a JSON file in the mod's folder.
/// The model type. This should be a plain class that has public properties for the data you want. The properties can be complex types.
/// The file path relative to the mod folder.
/// The arbitrary data to save, or null to delete the file.
/// The is not relative or contains directory climbing (../).
void WriteJsonFile(string path, TModel data) where TModel : class;
/****
** Save file
****/
/// Read arbitrary data stored in the current save slot. This is only possible if a save has been loaded.
/// The model type. This should be a plain class that has public properties for the data you want. The properties can be complex types.
/// The unique key identifying the data.
/// Returns the parsed data, or null if the entry doesn't exist or is empty.
/// The player hasn't loaded a save file yet or isn't the main player.
TModel ReadSaveData(string key) where TModel : class;
/// Save arbitrary data to the current save slot. This is only possible if a save has been loaded, and the data will be lost if the player exits without saving the current day.
/// The model type. This should be a plain class that has public properties for the data you want. The properties can be complex types.
/// The unique key identifying the data.
/// The arbitrary data to save, or null to remove the entry.
/// The player hasn't loaded a save file yet or isn't the main player.
void WriteSaveData(string key, TModel data) where TModel : class;
/****
** Global app data
****/
/// Read arbitrary data stored on the local computer, synchronised by GOG/Steam if applicable.
/// The model type. This should be a plain class that has public properties for the data you want. The properties can be complex types.
/// The unique key identifying the data.
/// Returns the parsed data, or null if the entry doesn't exist or is empty.
TModel ReadGlobalData(string key) where TModel : class;
/// Save arbitrary data to the local computer, synchronised by GOG/Steam if applicable.
/// The model type. This should be a plain class that has public properties for the data you want. The properties can be complex types.
/// The unique key identifying the data.
/// The arbitrary data to save, or null to delete the file.
void WriteGlobalData(string key, TModel data) where TModel : class;
}
}