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
min
TThe lower bound of the value range.
max
TThe upper bound of the value range.
comparer
IComparer<T>The comparer to use to determine whether values fall into the range of this config item.
Exceptions
- ArgumentNullException
When
min
ormax
are null.- NotSupportedException
When
comparer
is null whileT
is 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
config
IDefiningConfigKey<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
value
TThe value to test.
Returns
- bool
true
if the value falls into the range; otherwise,false
.