diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-11-16 17:52:49 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2016-11-16 17:52:49 -0500 |
commit | eb39f3d5ea28f004ab352113d869ae6d7772bcd5 (patch) | |
tree | f9c19a0d12939d822d9e24478b093086b7b9ecc7 /src/StardewModdingAPI/IModHelper.cs | |
parent | 962178352b711796ea0962a3fbcaf5b788037719 (diff) | |
download | SMAPI-eb39f3d5ea28f004ab352113d869ae6d7772bcd5.tar.gz SMAPI-eb39f3d5ea28f004ab352113d869ae6d7772bcd5.tar.bz2 SMAPI-eb39f3d5ea28f004ab352113d869ae6d7772bcd5.zip |
use interface for IModHelper
Diffstat (limited to 'src/StardewModdingAPI/IModHelper.cs')
-rw-r--r-- | src/StardewModdingAPI/IModHelper.cs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/StardewModdingAPI/IModHelper.cs b/src/StardewModdingAPI/IModHelper.cs new file mode 100644 index 00000000..1af7df6b --- /dev/null +++ b/src/StardewModdingAPI/IModHelper.cs @@ -0,0 +1,43 @@ +namespace StardewModdingAPI +{ + /// <summary>Provides methods for interacting with a mod directory.</summary> + public interface IModHelper + { + /********* + ** Accessors + *********/ + /// <summary>The mod directory path.</summary> + string DirectoryPath { get; } + + + /********* + ** Public methods + *********/ + /**** + ** Mod config file + ****/ + /// <summary>Read the mod's configuration file (and create it if needed).</summary> + /// <typeparam name="TConfig">The config class type. This should be a plain class that has public properties for the settings you want. These can be complex types.</typeparam> + TConfig ReadConfig<TConfig>() where TConfig : class, new(); + + /// <summary>Save to the mod's configuration file.</summary> + /// <typeparam name="TConfig">The config class type.</typeparam> + /// <param name="config">The config settings to save.</param> + void WriteConfig<TConfig>(TConfig config) where TConfig : class, new(); + + /**** + ** Generic JSON files + ****/ + /// <summary>Read a JSON file.</summary> + /// <typeparam name="TModel">The model type.</typeparam> + /// <param name="path">The file path relative to the mod directory.</param> + /// <returns>Returns the deserialised model, or <c>null</c> if the file doesn't exist or is empty.</returns> + TModel ReadJsonFile<TModel>(string path) where TModel : class; + + /// <summary>Save to a JSON file.</summary> + /// <typeparam name="TModel">The model type.</typeparam> + /// <param name="path">The file path relative to the mod directory.</param> + /// <param name="model">The model to save.</param> + void WriteJsonFile<TModel>(string path, TModel model) where TModel : class; + } +}
\ No newline at end of file |