Search Results for

    Show / Hide Table of Contents

    Class ValueParserProvider

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

    Inheritance
    System.Object
    ValueParserProvider
    Namespace: McMaster.Extensions.CommandLineUtils.Abstractions
    Assembly: McMaster.Extensions.CommandLineUtils.dll
    Syntax
    public class ValueParserProvider

    Properties

    | Improve this Doc View Source

    ParseCulture

    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 Source

    Add(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

    parser is null.

    | Improve this Doc View Source

    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

    parser is null.

    | Improve this Doc View Source

    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

    parsers is null.

    | Improve this Doc View Source

    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
    | Improve this Doc View Source

    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.

    • Improve this Doc
    • View Source
    In This Article
    Back to top