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, IDisplayable
- Inherited Members
- Extension Methods
Properties
Config
Gets the config this item belongs to.
Config Config { get; }
Property Value
HasChanges
Gets or sets whether this config item has unsaved changes.
bool HasChanges { get; set; }
Property Value
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
valueobjectThe value to set.
eventLabelstringThe custom label that may be set by whoever changed the config.
Exceptions
- ArgumentException
The
valuedidn'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
defaultValueobjectThe computed default value if the return value is
true. Otherwisedefault.
Returns
- bool
trueif 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
trueif 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
valueobjectThe value to set.
eventLabelstringThe custom label that may be set by whoever changed the config.
Returns
- bool
trueif 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
valueobjectThe value to check.
Returns
- bool
trueif the value is valid.
Events
Changed
Triggered when the internal value of this config item changes.
event ConfigKeyChangedEventHandler? Changed