Class ConfigKeyRange<T>
- Namespace
- MonkeyLoader.Configuration
- Assembly
- MonkeyLoader.dll
Implements a range component for IDefiningConfigKey<T>s using min and max values with a IComparer<T>.
public class ConfigKeyRange<T> : IConfigKeyRange<T>, IConfigKeyValidator<T>, IConfigKeyComponent<IDefiningConfigKey<T>>, IComponent<IDefiningConfigKey<T>>
Type Parameters
T
- Inheritance
-
ConfigKeyRange<T>
- Implements
- Inherited Members
Remarks
This class also implements IConfigKeyValidator<T> and is therefore two components in one.
Constructors
ConfigKeyRange(T?, T?, IComparer<T?>?)
Creates a new range component.
public ConfigKeyRange(T? min = default, T? max = default, IComparer<T?>? comparer = null)
Parameters
minTThe lower bound of the value range.
maxTThe upper bound of the value range.
comparerIComparer<T>The comparer to use to determine whether values fall into the range of this config item.
Exceptions
- ArgumentNullException
When
minormaxare null.- NotSupportedException
When
compareris null whileTis not IComparable<T>
Properties
Comparer
Gets the typed comparer used to check whether new values fall into this config item's range.
public IComparer<T?> Comparer { get; }
Property Value
- IComparer<T>
Max
Gets the typed upper bound of this config item's value range.
public T Max { get; }
Property Value
- T
Min
Gets the typed lower bound of this config item's value range.
public T Min { get; }
Property Value
- T
Methods
Initialize(IDefiningConfigKey<T>)
Initializes this component when it's added to an
entity's component list.
This may throw a InvalidOperationException when the state of the given entity is invalid for this component.
public void Initialize(IDefiningConfigKey<T> config)
Parameters
configIDefiningConfigKey<T>
Exceptions
- InvalidOperationException
When the state of the given entity is invalid.
IsValueInRange(T)
Determines whether the given value falls into this config item's range.
public bool IsValueInRange(T value)
Parameters
valueTThe value to test.
Returns
- bool
trueif the value falls into the range; otherwise,false.