api:umfconfig:parser_umfconfigdouble
Description:
Default double parser.
Added In: v0.45
Function
public class UMFConfigDouble : UMFConfigParser<double> { public double DefaultValue; public double MinValue; public double MaxValue; public int Decimals; public double VanillaValue; public bool RequiresRestart; public double[] AllowedValues; public UMFConfigDouble(double defaultValue = default(double), double minValue = default(double), double maxValue = default(double), int decimals = 2, double vanillaValue = default(double), bool requiresRestart = false, params double[] allowedValues) { DefaultValue = defaultValue; MinValue = Math.Min(minValue, maxValue); MaxValue = Math.Max(minValue, maxValue); Decimals = decimals; VanillaValue = vanillaValue; RequiresRestart = requiresRestart; AllowedValues = allowedValues; } public override double Parse(string value) { if (!double.TryParse(value, out double result)) result = DefaultValue; return result; } public override string ToString() { return DefaultValue.ToString(); } public override string Default() { return DefaultValue.ToString(); } public override string Range() { return (MaxValue != default(double) ? MinValue.ToString() + "," + MaxValue.ToString() + "," + Decimals.ToString() : null); } public override string Vanilla() { return (VanillaValue != default(double) ? VanillaValue.ToString() : null); } public override string Allowed() { return (AllowedValues.Length > 0 ? string.Join(",", AllowedValues.Select(x => x.ToString()).ToArray()) : null); } public override string Restart() { return RequiresRestart.ToString(); } }
Usage
//Coming soon
Examples
//Coming soon
api/umfconfig/parser_umfconfigdouble.txt · Last modified: 2019/06/29 22:36 by umfdev