mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-20 01:46:13 +00:00
Expose AcceptableValueList.AcceptableValues
This commit is contained in:
1 parent
b60442ed5e
commit
6abda092cb
1 file changed
+8
-5
@@ -8,7 +8,10 @@ namespace BepInEx.Configuration
|
||||
/// </summary>
|
||||
public sealed class AcceptableValueList<T> : AcceptableValueBase where T : IEquatable<T>
|
||||
{
|
||||
private readonly T[] _acceptableValues;
|
||||
/// <summary>
|
||||
/// List of values that a setting can take.
|
||||
/// </summary>
|
||||
public T[] AcceptableValues { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Specify the list of acceptable values for a setting.
|
||||
@@ -19,7 +22,7 @@ namespace BepInEx.Configuration
|
||||
if (acceptableValues == null) throw new ArgumentNullException(nameof(acceptableValues));
|
||||
if (acceptableValues.Length == 0) throw new ArgumentException("At least one acceptable value is needed", nameof(acceptableValues));
|
||||
|
||||
_acceptableValues = acceptableValues;
|
||||
AcceptableValues = acceptableValues;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -28,19 +31,19 @@ namespace BepInEx.Configuration
|
||||
if (IsValid(value))
|
||||
return value;
|
||||
|
||||
return _acceptableValues[0];
|
||||
return AcceptableValues[0];
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool IsValid(object value)
|
||||
{
|
||||
return value is T v && _acceptableValues.Any(x => x.Equals(v));
|
||||
return value is T v && AcceptableValues.Any(x => x.Equals(v));
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToSerializedString()
|
||||
{
|
||||
return "# Acceptable values: " + string.Join(", ", _acceptableValues.Select(x => x.ToString()).ToArray());
|
||||
return "# Acceptable values: " + string.Join(", ", AcceptableValues.Select(x => x.ToString()).ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user