Class ArgumentEnumProvider<TEnum>
- Namespace
- Webefinity.Switch
- Assembly
- Switch.dll
A value provider that captures a string value and converts it to an enumeration value which is equivalent to that string value. Usage provides the string variants of each of your enum values automatically.
public class ArgumentEnumProvider<TEnum> : IValueProvider where TEnum : Enum
Type Parameters
TEnum
- Inheritance
-
ArgumentEnumProvider<TEnum>
- Implements
- Inherited Members
Constructors
ArgumentEnumProvider(object?)
Construct a new enum provider with an optional default value
public ArgumentEnumProvider(object? value = null)
Parameters
value
object
Properties
DefaultValue
The default value if there is one. If a switch is followed only by another switch, the default value will be used by the handler.
public object? DefaultValue { get; }
Property Value
Value
The value of the option, stored as a boxed value according to the type the handler should produce.
public object? Value { get; }
Property Value
WasSet
Indicates whether the value was set by command line processing. This should be set by the call to the Set method.
public bool WasSet { get; }
Property Value
Methods
Set(string?)
Called by the ArgumentsHandler to set the value of the option in the provider. Should set WasSet to true if the value was used, regardless of its validity.
public ValidationResult Set(string? value)
Parameters
value
stringThe value of the option as provided on the command line.
Returns
- ValidationResult
An validation result, either success, or with errors. If errors are returned the entire command line is considered invalid by the handler.
Usage(Action<string>)
Returns a string for the usage description that describes show to set the value. A true/false flag might return "true, false" here.
public void Usage(Action<string> log)