Table of Contents

Class ValueParserProvider

Namespace
McMaster.Extensions.CommandLineUtils.Abstractions
Assembly
McMaster.Extensions.CommandLineUtils.dll

A store of value parsers that are used to convert argument values from strings to types.

public class ValueParserProvider
Inheritance
object
ValueParserProvider

Properties

ParseCulture

Gets or sets the CultureInfo which is used to convert argument values to types.

public CultureInfo ParseCulture { get; set; }

Property Value

CultureInfo

Remarks

The default value is CurrentCulture.

Methods

Add(IValueParser)

Add a new value parser to the provider.

public void Add(IValueParser parser)

Parameters

parser IValueParser

An instance of the parser that is used to convert an argument from a string.

Exceptions

ArgumentException

A value parser with the same TargetType is already registered.

ArgumentNullException

parser is null.

AddOrReplace(IValueParser)

Add a new value parser to the provider, or if a value provider already exists for TargetType then replaces it with parser.

public void AddOrReplace(IValueParser parser)

Parameters

parser IValueParser

An instance of the parser that is used to convert an argument from a string.

Exceptions

ArgumentNullException

parser is null.

AddRange(IEnumerable<IValueParser>)

Add collection of a new value parsers to the provider.

public void AddRange(IEnumerable<IValueParser> parsers)

Parameters

parsers IEnumerable<IValueParser>

The collection whose parsers should be added.

Exceptions

ArgumentException

A value parser with the same TargetType is already registered.

ArgumentNullException

parsers is null.

GetParser(Type)

Returns a parser registered for the given type.

public IValueParser GetParser(Type type)

Parameters

type Type

Returns

IValueParser

GetParser<T>()

Returns a parser for the generic type T.

public IValueParser<T>? GetParser<T>()

Returns

IValueParser<T>

Type Parameters

T

Remarks

If parser is not registered, null is returned.