Interface IDefiningConfigKey
- Namespace
- MonkeyLoader.Configuration
- Assembly
- MonkeyLoader.dll
Defines the definition for a config item.
public interface IDefiningConfigKey : ITypedConfigKey, IConfigKey, IEquatable<IConfigKey>, IEntity<IDefiningConfigKey>, IEnumerable<IComponent<IDefiningConfigKey>>, IEnumerable, INestedIdentifiable<ConfigSection>, INestedIdentifiable, IIdentifiable, IPrioritizable
- Inherited Members
- Extension Methods
Properties
Config
Gets the config this item belongs to.
Config Config { get; }
Property Value
Description
Gets the human-readable description of this config item.
string? Description { get; }
Property Value
HasChanges
Gets or sets whether this config item has unsaved changes.
bool HasChanges { get; set; }
Property Value
HasDescription
Gets whether this config item has a human-readable description.
bool HasDescription { get; }
Property Value
- bool
true
if Description is notnull
; otherwise,false
.
HasValue
Gets whether this config item has a set value.
bool HasValue { get; }
Property Value
Remarks
Should be automatomatically set to true
when a different value is set.
InternalAccessOnly
Gets whether only the owning mod should have access to this config item.
bool InternalAccessOnly { get; }
Property Value
Section
Gets the ConfigSection this item belongs to.
ConfigSection Section { get; set; }
Property Value
Remarks
Should only be set once when the owning ConfigSection is initializing.
Methods
GetValue()
Gets this config item's set value, falling back to the computed default.
object? GetValue()
Returns
Reset()
Removes this config item's value and attempts to reset it back to its default.
void Reset()
SetValue(object?, string?)
Set the config item's internal value to the given one.
void SetValue(object? value, string? eventLabel = null)
Parameters
value
objectThe value to set.
eventLabel
stringThe custom label that may be set by whoever changed the config.
Exceptions
- ArgumentException
The
value
didn't pass validation.
TryComputeDefault(out object?)
Tries to compute the default value for this key, if a default provider was set.
bool TryComputeDefault(out object? defaultValue)
Parameters
defaultValue
objectThe computed default value if the return value is
true
. Otherwisedefault
.
Returns
- bool
true
if the default value was successfully computed.
TryGetValue(out object?)
Tries to get this config item's set value, falling back to the computed default.
bool TryGetValue(out object? value)
Parameters
Returns
- bool
true
if the config item's value was set or a default could be computer, otherwisefalse
.
TrySetValue(object?, string?)
Tries to set the config item's internal value to the given one if it passes validation.
bool TrySetValue(object? value, string? eventLabel = null)
Parameters
value
objectThe value to set.
eventLabel
stringThe custom label that may be set by whoever changed the config.
Returns
- bool
true
if the value was successfully set, otherwisefalse
.
Unset()
Removes this config item's value, setting it to its type's default
.
bool Unset()
Returns
- bool
Whether there was a value to remove.
Validate(object?)
Checks if a value is valid for this config item.
bool Validate(object? value)
Parameters
value
objectThe value to check.
Returns
- bool
true
if the value is valid.
Events
Changed
Triggered when the internal value of this config item changes.
event ConfigKeyChangedEventHandler? Changed