EnumConverter Class

A converter for arguments with enumeration values.

Definition

Namespace: Ookii.CommandLine.Conversion
Assembly: Ookii.CommandLine (in Ookii.CommandLine.dll) Version: 4.0.0+bb7ed9a8fdfd1cb21824750a8cf508863ad15086
C#
public class EnumConverter : ArgumentConverter
Inheritance
Object    ArgumentConverter    EnumConverter

Remarks

This converter performs a case insensitive conversion, and accepts the name of an enumeration value, or its underlying value. In the latter case, the value does not need to be one of the defined values of the enumeration; use the ValidateEnumValueAttribute attribute to ensure only defined enumeration values can be used.

A comma-separated list of values is also accepted, which will be combined using a bitwise-or operation. This is accepted regardless of whether the enumeration uses the FlagsAttribute attribute.

If conversion fails, this converter will provide an error message that includes all the allowed values for the enumeration.

Constructors

EnumConverter Initializes a new instance of the EnumConverter for the specified enumeration type.

Properties

EnumType Gets the enumeration type that this converter converts to.

Methods

Convert(ReadOnlySpanChar, CultureInfo, CommandLineArgument) Converts a string span to the enumeration type.
(Overrides ArgumentConverterConvert(ReadOnlySpanChar, CultureInfo, CommandLineArgument))
Convert(String, CultureInfo, CommandLineArgument) Converts a string to the enumeration type.
(Overrides ArgumentConverterConvert(String, CultureInfo, CommandLineArgument))
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
ToStringReturns a string that represents the current object.
(Inherited from Object)

Thread Safety

Static members of this type are safe for multi-threaded operations. Instance members of this type are safe for multi-threaded operations.

See Also