Class Config<T>
Allows mods to save config.
public class Config<T> where T : class
Type Parameters
T
- Inheritance
-
Config<T>
- Inherited Members
Constructors
Config(string, ConfigTypes)
public Config(string modName, Config<T>.ConfigTypes configType)
Parameters
modNamestringconfigTypeConfig<T>.ConfigTypes
Methods
Edit(Action<T>)
Edits the config. Should only be called after setting a default.
public void Edit(Action<T> editor)
Parameters
editorAction<T>
Remarks
Call SaveChanges after editing
Get()
Gets the config. Should only be called after setting a default.
public T Get()
Returns
- T
Get<TResult>(Func<T, TResult>)
Gets part of the config. Should only be called after setting a default
public TResult Get<TResult>(Func<T, TResult> getter)
Parameters
getterFunc<T, TResult>
Returns
- TResult
Type Parameters
TResult
SaveChanges()
Writes the config to disk
public void SaveChanges()
SetDefaultConfig(T)
Sets the default if the config does not exist yet. Always call this before reading from the config.
public void SetDefaultConfig(T defaultValue)
Parameters
defaultValueT
Write(T)
Writes the entire config. Usage not recommended, use Edit() instead
public void Write(T config)
Parameters
configT