Class ValueParserProvider
A store of value parsers that are used to convert argument values from strings to types.
Inheritance
Namespace: McMaster.Extensions.CommandLineUtils.Abstractions
Assembly: McMaster.Extensions.CommandLineUtils.dll
Syntax
public class ValueParserProvider
Properties
| Improve this Doc View SourceParseCulture
Gets or sets the CultureInfo which is used to convert argument values to types.
Declaration
public CultureInfo ParseCulture { get; set; }
Property Value
Type | Description |
---|---|
System. |
Remarks
The default value is System.
Methods
| Improve this Doc View SourceAdd(IValueParser)
Add a new value parser to the provider.
Declaration
public void Add(IValueParser parser)
Parameters
Type | Name | Description |
---|---|---|
IValue |
parser | An instance of the parser that is used to convert an argument from a string. |
Exceptions
Type | Condition |
---|---|
System. |
A value parser with the same Target |
System. |
|
AddOrReplace(IValueParser)
Add a new value parser to the provider, or if a value provider already exists for
Targetparser
.
Declaration
public void AddOrReplace(IValueParser parser)
Parameters
Type | Name | Description |
---|---|---|
IValue |
parser | An instance of the parser that is used to convert an argument from a string. |
Exceptions
Type | Condition |
---|---|
System. |
|
AddRange(IEnumerable<IValueParser>)
Add collection of a new value parsers to the provider.
Declaration
public void AddRange(IEnumerable<IValueParser> parsers)
Parameters
Type | Name | Description |
---|---|---|
System. |
parsers | The collection whose parsers should be added. |
Exceptions
Type | Condition |
---|---|
System. |
A value parser with the same Target |
System. |
|
GetParser(Type)
Returns a parser registered for the given type.
Declaration
public IValueParser GetParser(Type type)
Parameters
Type | Name | Description |
---|---|---|
System. |
type |
Returns
Type | Description |
---|---|
IValue |
GetParser<T>()
Returns a parser for the generic type T.
Declaration
public IValueParser<T> GetParser<T>()
Returns
Type | Description |
---|---|
IValue |
Type Parameters
Name | Description |
---|---|
T |
Remarks
If parser is not registered, null is returned.