Table of Contents

Class Config<T>

Namespace
PolyMod.Api
Assembly
PolyMod.dll

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

modName string
configType Config<T>.ConfigTypes

Methods

Edit(Action<T>)

Edits the config. Should only be called after setting a default.

public void Edit(Action<T> editor)

Parameters

editor Action<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

getter Func<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

defaultValue T

Write(T)

Writes the entire config. Usage not recommended, use Edit() instead

public void Write(T config)

Parameters

config T