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.Globalization.CultureInfo |
Remarks
The default value is System.Globalization.CultureInfo.CurrentCulture.
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 |
---|---|---|
IValueParser | parser | An instance of the parser that is used to convert an argument from a string. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | A value parser with the same TargetType is already registered. |
System.ArgumentNullException |
|
AddOrReplace(IValueParser)
Add a new value parser to the provider, or if a value provider already exists for
TargetType then replaces it with parser
.
Declaration
public void AddOrReplace(IValueParser parser)
Parameters
Type | Name | Description |
---|---|---|
IValueParser | parser | An instance of the parser that is used to convert an argument from a string. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException |
|
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.Collections.Generic.IEnumerable<IValueParser> | parsers | The collection whose parsers should be added. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | A value parser with the same TargetType is already registered. |
System.ArgumentNullException |
|
GetParser(Type)
Returns a parser registered for the given type.
Declaration
public IValueParser GetParser(Type type)
Parameters
Type | Name | Description |
---|---|---|
System.Type | type |
Returns
Type | Description |
---|---|
IValueParser |
GetParser<T>()
Returns a parser for the generic type T.
Declaration
public IValueParser<T> GetParser<T>()
Returns
Type | Description |
---|---|
IValueParser<T> |
Type Parameters
Name | Description |
---|---|
T |
Remarks
If parser is not registered, null is returned.