Class OptionsState
- Namespace
- ConfigurableWarning.API.State
- Assembly
- RedstoneWizard08.ContentLibrary.dll
The class responsible for storing options' values.
public class OptionsState
- Inheritance
-
OptionsState
- Inherited Members
Properties
Instance
The current instance of this OptionsState.
public static OptionsState Instance { get; }
Property Value
Methods
Apply(string)
Replaces all states with the JSON-encoded map provided, removing any not present in the provided string, and replacing all that are already present.
public void Apply(string json)
Parameters
json
stringThe JSON-encoded map.
Clear()
Clears all states from the internal dictionary, unregistering all of its options. This does NOT unregister ANYTHING from the OptionManager or ContentSettings' SettingsLoader.
public void Clear()
Collect()
Collect and serialize (with Newtonsoft.Json.JsonConvert) all registered states to a JSON string.
public string Collect()
Returns
- string
The JSON-formatted states.
Get<T>(IOption<T>)
Gets the value of an option. This will forward to Get<T>(string) based on GetName().
public T? Get<T>(IOption<T> opt)
Parameters
opt
IOption<T>The option to reference.
Returns
- T
The option's value.
Type Parameters
T
The option's value type.
Get<T>(string)
Gets an option's value from the internal storage.
public T? Get<T>(string name)
Parameters
name
stringThe option's name.
Returns
- T
The option's value.
Type Parameters
T
The value type.
Has(string)
Returns true if the option is registered in the state.
public bool Has(string name)
Parameters
name
stringThe option's name.
Returns
- bool
True if the option has a value in the state.
Has<T>(IOption<T>)
Returns true if the option is registered in the state.
public bool Has<T>(IOption<T> opt)
Parameters
opt
IOption<T>The option to reference.
Returns
- bool
True if the option has a value in the state.
Type Parameters
T
The option's value type.
Register<T>(IOption<T>)
Registers a typed option to the state.
public void Register<T>(IOption<T> opt)
Parameters
opt
IOption<T>The option to register.
Type Parameters
T
The option's value type.
Remove(string)
Removes the option's value from the state, unregistering it. This does NOT unregister it from the OptionManager or ContentSettings' SettingsLoader.
public void Remove(string name)
Parameters
name
stringThe option's name.
Remove<T>(IOption<T>)
Removes the option's value from the state, unregistering it. This does NOT unregister it from the OptionManager or ContentSettings' SettingsLoader.
public void Remove<T>(IOption<T> opt)
Parameters
opt
IOption<T>The option to remove.
Type Parameters
T
The option's value type.
Set<T>(IOption<T>, T)
Sets the provided option's state.
public void Set<T>(IOption<T> opt, T value)
Parameters
opt
IOption<T>The option to set for.
value
TThe new value.
Type Parameters
T
The option's value type.
Set<T>(string, T)
Sets the state based on the option's name.
public void Set<T>(string name, T value)
Parameters
name
stringThe option's name.
value
TThe new value.
Type Parameters
T
The value type.
Update<T>(IOption<T>)
Updates an option's value in the state. This will set the value in the state to its contained value.
public void Update<T>(IOption<T> opt)
Parameters
opt
IOption<T>The option.
Type Parameters
T
The option's value type.