Table of Contents

Class ParserExtension

Namespace
MASES.CLIParser
Assembly
MASES.CLIParser.dll

Helper methods for the Parser class

public static class ParserExtension
Inheritance
ParserExtension
Inherited Members

Methods

Add(IArgumentMetadata)

public static void Add(this IArgumentMetadata metadata)

Parameters

metadata IArgumentMetadata

Add(IEnumerable<IArgumentMetadata>)

Adds a collection of IArgumentMetadata

public static void Add(this IEnumerable<IArgumentMetadata> metadatas)

Parameters

metadatas IEnumerable<IArgumentMetadata>

The collection of IArgumentMetadata to add

Exist(IEnumerable<IArgumentMetadataParsed>, string)

Check the args for existing name

public static bool Exist(this IEnumerable<IArgumentMetadataParsed> args, string name)

Parameters

args IEnumerable<IArgumentMetadataParsed>

Arguments to test using the list prepared using Parse

name string

Argument name to search

Returns

bool

true if the the argument with name name exist

Exists(IEnumerable<IArgumentMetadataParsed>)

Filter the args for existing IArgumentMetadataParsed

public static IEnumerable<IArgumentMetadataParsed> Exists(this IEnumerable<IArgumentMetadataParsed> args)

Parameters

args IEnumerable<IArgumentMetadataParsed>

Arguments to test using the list prepared using Parse

Returns

IEnumerable<IArgumentMetadataParsed>

A filtered list of IArgumentMetadataParsed

Get(IEnumerable<IArgumentMetadataParsed>, int)

Return the IArgumentMetadataParsed at index

public static IArgumentMetadataParsed Get(this IEnumerable<IArgumentMetadataParsed> args, int index)

Parameters

args IEnumerable<IArgumentMetadataParsed>

An ensemble of IArgumentMetadataParsed to parse

index int

Index to get

Returns

IArgumentMetadataParsed

The selected IArgumentMetadataParsed

Get(IEnumerable<IArgumentMetadataParsed>, string)

Return the IArgumentMetadataParsed at name

public static IArgumentMetadataParsed Get(this IEnumerable<IArgumentMetadataParsed> args, string name)

Parameters

args IEnumerable<IArgumentMetadataParsed>

An ensemble of IArgumentMetadataParsed to parse

name string

The argument name, or short name, to get

Returns

IArgumentMetadataParsed

The selected IArgumentMetadataParsed

Get(IEnumerable<IArgumentMetadata>, int)

Return the IArgumentMetadata at index

public static IArgumentMetadata Get(this IEnumerable<IArgumentMetadata> args, int index)

Parameters

args IEnumerable<IArgumentMetadata>

An ensemble of IArgumentMetadata to parse

index int

Index to get

Returns

IArgumentMetadata

The selected IArgumentMetadata

Get(IEnumerable<IArgumentMetadata>, string)

Return the IArgumentMetadata at name

public static IArgumentMetadata Get(this IEnumerable<IArgumentMetadata> args, string name)

Parameters

args IEnumerable<IArgumentMetadata>

An ensemble of IArgumentMetadata to parse

name string

The argument name, or short name, to get

Returns

IArgumentMetadata

The selected IArgumentMetadata

Get<T>(IArgumentMetadataParsed)

Return the value from IArgumentMetadataParsed or the default value

public static T Get<T>(this IArgumentMetadataParsed arg)

Parameters

arg IArgumentMetadataParsed

The IArgumentMetadataParsed to use to get value

Returns

T

The value from IArgumentMetadataParsed or Default if value was not set

Type Parameters

T

The Type to use to retrieve value

Get<T>(IEnumerable<IArgumentMetadataParsed>, int)

Return the value of the IArgumentMetadataParsed ensemble at index

public static T Get<T>(this IEnumerable<IArgumentMetadataParsed> args, int index)

Parameters

args IEnumerable<IArgumentMetadataParsed>

An ensemble of IArgumentMetadataParsed to parse

index int

Index to get

Returns

T

The value from IArgumentMetadataParsed

Type Parameters

T

Get<T>(IEnumerable<IArgumentMetadataParsed>, string)

Return the value of the IArgumentMetadataParsed ensemble at name

public static T Get<T>(this IEnumerable<IArgumentMetadataParsed> args, string name)

Parameters

args IEnumerable<IArgumentMetadataParsed>

An ensemble of IArgumentMetadataParsed to parse

name string

The argument name, or short name, to get

Returns

T

The value from IArgumentMetadataParsed

Type Parameters

T

NotExists(IEnumerable<IArgumentMetadataParsed>)

Filter the args for non existing IArgumentMetadataParsed

public static IEnumerable<IArgumentMetadataParsed> NotExists(this IEnumerable<IArgumentMetadataParsed> args)

Parameters

args IEnumerable<IArgumentMetadataParsed>

Arguments to test using the list prepared using Parse

Returns

IEnumerable<IArgumentMetadataParsed>

A filtered list of IArgumentMetadataParsed

Override(IEnumerable<IArgumentMetadataParsed>, IEnumerable<IArgumentMetadataParsed>, bool)

Overrides values in destination with values found in source

public static IEnumerable<IArgumentMetadataParsed> Override(this IEnumerable<IArgumentMetadataParsed> destination, IEnumerable<IArgumentMetadataParsed> source, bool rawReplace = false)

Parameters

destination IEnumerable<IArgumentMetadataParsed>

An ensemble of IArgumentMetadataParsed

source IEnumerable<IArgumentMetadataParsed>

An ensemble of IArgumentMetadataParsed

rawReplace bool

Replace destionation without check if argument exist in the source

Returns

IEnumerable<IArgumentMetadataParsed>

The updated destination

Prefix(ArgumentPrefix, string)

Convert an ArgumentPrefix to the equivalent string representation

public static string Prefix(this ArgumentPrefix prefix, string customPrefix = null)

Parameters

prefix ArgumentPrefix

The ArgumentPrefix to convert in string

customPrefix string

The custom prefix associated to prefix with a value of Custom

Returns

string

RemoveFile(IEnumerable<IArgumentMetadataParsed>)

Return the IArgumentMetadataParsed without any accurrence of file argument (i.e. IsFile is true)

public static IEnumerable<IArgumentMetadataParsed> RemoveFile(this IEnumerable<IArgumentMetadataParsed> args)

Parameters

args IEnumerable<IArgumentMetadataParsed>

An ensemble of IArgumentMetadataParsed to check

Returns

IEnumerable<IArgumentMetadataParsed>

A list of IArgumentMetadataParsed

ToString(IArgumentMetadata, params object[])

Creates the command line switch associated to the metadata and values

public static string ToString(this IArgumentMetadata metadata, params object[] values)

Parameters

metadata IArgumentMetadata

The IArgumentMetadata switch

values object[]

The value(s) to use. Multiple value can be used in case of argument reports IsMultiValue to be true

Returns

string

The string equivalent for command-line

ToString(IEnumerable<IArgumentMetadata>, string, params object[])

Creates the command line switch associated to the switch with name and value

public static string ToString(this IEnumerable<IArgumentMetadata> metadatas, string name, params object[] values)

Parameters

metadatas IEnumerable<IArgumentMetadata>

An ensemble of IArgumentMetadata with all possible arguments

name string

The command-line switch name

values object[]

The value(s) to use. Multiple value can be used in case of argument reports IsMultiValue as true

Returns

string

The string equivalent for command-line