Table of Contents

CliBindingContext.GetArgumentParser Method

Definition

Namespace
DotMake.CommandLine
Assembly
DotMake.CommandLine.dll

GetArgumentParser<TCollection, TItem>(Func<Array, TCollection>, Func<string, TItem>)

Gets an argument parser method for an argument type, if it's a collection type.

This is mainly used for adding support for all IEnumerable<T> compatible types which have a public constructor with a IEnumerable<T> or IList<T> parameter (other parameters, if any, should be optional).

public Func<ArgumentResult, TCollection> GetArgumentParser<TCollection, TItem>(Func<Array, TCollection> convertFromArray, Func<string, TItem> convertFromString = null)

Parameters

convertFromArray Func<Array, TCollection>

A delegate which creates an instance of collection type from an array.

convertFromString Func<string, TItem>

A delegate which creates an instance of item type from a string.

Returns

Func<ArgumentResult, TCollection>

A delegate which can be passed to an option or argument.

Type Parameters

TCollection

The collection type, the argument type itself.

TItem

The item type, e.g. if argument type is IEnumerable<T>, item type will be T.

GetArgumentParser<TArgument>(Func<string, TArgument>)

Gets an argument parser method for an argument type.

This is mainly used for adding support for binding custom types which have a public constructor or a static Parse method with a string parameter (other parameters, if any, should be optional).

public Func<ArgumentResult, TArgument> GetArgumentParser<TArgument>(Func<string, TArgument> convertFromString = null)

Parameters

convertFromString Func<string, TArgument>

A delegate which creates an instance of custom type from a string.

Returns

Func<ArgumentResult, TArgument>

A delegate which can be passed to an option or argument.

Type Parameters

TArgument

The argument type.