Class SaveDataCache
An abstract implementation of IJsonFile intended for use with caching per-save data.
public abstract class SaveDataCache : JsonFile, IJsonFile
- Inheritance
-
SaveDataCache
- Implements
- Inherited Members
- Extension Methods
Constructors
SaveDataCache()
Creates a new instance of SaveDataCache, parsing the file name from FileNameAttribute
if declared, or with default values otherwise.
public SaveDataCache()
Properties
JsonFilePath
The file path at which the JSON file is accessible for reading and writing.
public override string JsonFilePath { get; }
Property Value
Methods
Load(bool)
Loads the JSON properties from the file on disk into the SaveDataCache.
If you are overriding this in a subclass, be aware that SaveDataHandler. RegisterSaveDataCache<T>() calls the async load function LoadAsync(bool)!
If you are overriding this in a subclass, be aware that SaveDataHandler. RegisterSaveDataCache<T>() calls the async load function LoadAsync(bool)!
public override void Load(bool createFileIfNotExist = true)
Parameters
createFileIfNotExist
bool- Whether a new JSON file should be created with default values if it does not already exist.
Exceptions
- InvalidOperationException
- Thrown when the player is not in-game.
- See Also
LoadAsync(bool)
Loads the JSON properties from the file on disk into the SaveDataCache.
public override Task LoadAsync(bool createFileIfNotExist = true)
Parameters
createFileIfNotExist
bool- Whether a new JSON file should be created with default values if it does not already exist.
Returns
Exceptions
- InvalidOperationException
- Thrown when the player is not in-game.
- See Also
LoadWithConverters(bool, params JsonConverter[])
Loads the JSON properties from the file on disk into the SaveDataCache.
public override void LoadWithConverters(bool createFileIfNotExist = true, params JsonConverter[] jsonConverters)
Parameters
createFileIfNotExist
bool- Whether a new JSON file should be created with default values if it does not already exist.
jsonConverters
JsonConverter[]- Optional Newtonsoft.Json.JsonConverters to be used for serialization. The AlwaysIncludedJsonConverters will always be used, regardless of whether you pass them.
Exceptions
- InvalidOperationException
- Thrown when the player is not in-game.
- See Also
LoadWithConvertersAsync(bool, params JsonConverter[])
Loads the JSON properties from the file on disk into the SaveDataCache.
public override Task LoadWithConvertersAsync(bool createFileIfNotExist = true, params JsonConverter[] jsonConverters)
Parameters
createFileIfNotExist
bool- Whether a new JSON file should be created with default values if it does not already exist.
jsonConverters
JsonConverter[]- Optional Newtonsoft.Json.JsonConverters to be used for serialization. The AlwaysIncludedJsonConverters will always be used, regardless of whether you pass them.
Returns
Exceptions
- InvalidOperationException
- Thrown when the player is not in-game.
- See Also
Save()
Saves the current fields and properties of the SaveDataCache as JSON properties to the file on disk.
If you are overriding this in a subclass, be aware that SaveDataHandler. RegisterSaveDataCache<T>() calls the async saving function SaveAsync()!
If you are overriding this in a subclass, be aware that SaveDataHandler. RegisterSaveDataCache<T>() calls the async saving function SaveAsync()!
public override void Save()
Exceptions
- InvalidOperationException
- Thrown when the player is not in-game.
- See Also
SaveAsync()
Saves the current fields and properties of the SaveDataCache as JSON properties to the file on disk.
public override Task SaveAsync()
Returns
Exceptions
- InvalidOperationException
- Thrown when the player is not in-game.
- See Also
SaveWithConverters(params JsonConverter[])
Saves the current fields and properties of the SaveDataCache as JSON properties to the file on disk.
public override void SaveWithConverters(params JsonConverter[] jsonConverters)
Parameters
jsonConverters
JsonConverter[]- Optional Newtonsoft.Json.JsonConverters to be used for deserialization. The AlwaysIncludedJsonConverters will always be used, regardless of whether you pass them.
Exceptions
- InvalidOperationException
- Thrown when the player is not in-game.
- See Also
SaveWithConvertersAsync(params JsonConverter[])
Saves the current fields and properties of the SaveDataCache as JSON properties to the file on disk.
public override Task SaveWithConvertersAsync(params JsonConverter[] jsonConverters)
Parameters
jsonConverters
JsonConverter[]- Optional Newtonsoft.Json.JsonConverters to be used for deserialization. The AlwaysIncludedJsonConverters will always be used, regardless of whether you pass them.
Returns
Exceptions
- InvalidOperationException
- Thrown when the player is not in-game.
- See Also