Class CliOptionParser<T>
This class provides a routine to put application arguments into properties of an object of type T, where matching CliAttribute are applied to the properties.
Inheritance
Namespace: TeleScope.UI.Cli.Options
Assembly: TeleScope.UI.Cli.dll
Syntax
public class CliOptionParser<T> : object where T : new()
Type Parameters
Name | Description |
---|---|
T | The type of the arguments class. |
Constructors
| Improve this Doc View SourceCliOptionParser()
The default constructor creates a new instance of the options and sets the prefix to -
.
The format is set to InvariantCulture
.
Declaration
public CliOptionParser()
CliOptionParser(IFormatProvider)
The constructor calls the default constructor and overrides the Format property.
Declaration
public CliOptionParser(IFormatProvider format)
Parameters
Type | Name | Description |
---|---|---|
IFormatProvider | format | The format specifies how the strings are parsed into types of the target properties. |
CliOptionParser(String)
The constructor calls the default constructor and overrides the Prefix property.
Declaration
public CliOptionParser(string prefix)
Parameters
Type | Name | Description |
---|---|---|
System.String | prefix | The prefix that is used for identifying application arguments in the string array. |
CliOptionParser(String, IFormatProvider)
Declaration
public CliOptionParser(string prefix, IFormatProvider format)
Parameters
Type | Name | Description |
---|---|---|
System.String | prefix | The prefix that is used for identifying application arguments in the string array. |
IFormatProvider | format | The format specifies how the strings are parsed into types of the target properties. |
Properties
| Improve this Doc View SourceFormat
Gets or sets the format how the strings are parsed into types of the target properties.
Declaration
public IFormatProvider Format { get; set; }
Property Value
Type | Description |
---|---|
IFormatProvider |
Prefix
Gets or sets the Prefix that is used to identify options.
Declaration
public string Prefix { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceReadArguments(String[])
Reads the command line arguments and places them into the properties of the according instance of type T.
Declaration
public T ReadArguments(string[] args)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | args | The cli options of the main method. |
Returns
Type | Description |
---|---|
T | The resulting instance of type T. |