Show / Hide Table of Contents

Class ExtensionMethods

Extension methods. Mostly methods for configuring command argument definitions using fluent config methods.

Inheritance
object
ExtensionMethods
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Benday.CommandsFramework
Assembly: Benday.CommandsFramework.dll
Syntax
public static class ExtensionMethods

Methods

| Edit this page View Source

AddArgumentValue(CommandExecutionInfo, string, string)

Adds an argument value to the arguments in an execution info object

Declaration
public static void AddArgumentValue(this CommandExecutionInfo execInfo, string argName, string argValue)
Parameters
Type Name Description
CommandExecutionInfo execInfo

The execution information for the command

string argName

Argument name

string argValue

Argument value

Exceptions
Type Condition
ArgumentNullException
| Edit this page View Source

AddBoolean(ArgumentCollection, string)

Adds a boolean argument definition

Declaration
public static BooleanArgument AddBoolean(this ArgumentCollection collection, string argumentName)
Parameters
Type Name Description
ArgumentCollection collection

Argument collection

string argumentName

Argument name on the command line

Returns
Type Description
BooleanArgument
| Edit this page View Source

AddDateTime(ArgumentCollection, string)

Adds a datetime argument definition

Declaration
public static DateTimeArgument AddDateTime(this ArgumentCollection collection, string argumentName)
Parameters
Type Name Description
ArgumentCollection collection

Argument collection

string argumentName

Argument name on the command line

Returns
Type Description
DateTimeArgument
| Edit this page View Source

AddDirectory(ArgumentCollection, string)

Adds a directory argument definition

Declaration
public static DirectoryArgument AddDirectory(this ArgumentCollection collection, string argumentName)
Parameters
Type Name Description
ArgumentCollection collection

Argument collection

string argumentName

Argument name on the command line

Returns
Type Description
DirectoryArgument
| Edit this page View Source

AddFile(ArgumentCollection, string)

Adds a file argument definition

Declaration
public static FileArgument AddFile(this ArgumentCollection collection, string argumentName)
Parameters
Type Name Description
ArgumentCollection collection

Argument collection

string argumentName

Argument name on the command line

Returns
Type Description
FileArgument
| Edit this page View Source

AddInt32(ArgumentCollection, string)

Adds a int32 argument definition

Declaration
public static Int32Argument AddInt32(this ArgumentCollection collection, string argumentName)
Parameters
Type Name Description
ArgumentCollection collection

Argument collection

string argumentName

Argument name on the command line

Returns
Type Description
Int32Argument
| Edit this page View Source

AddString(ArgumentCollection, string)

Adds a string argument definition

Declaration
public static StringArgument AddString(this ArgumentCollection collection, string argumentName)
Parameters
Type Name Description
ArgumentCollection collection

Argument collection

string argumentName

Argument name on the command line

Returns
Type Description
StringArgument
| Edit this page View Source

AllowEmptyValue<T>(Argument<T>, bool)

Configures an argument definition to allow empty values

Declaration
public static Argument<T> AllowEmptyValue<T>(this Argument<T> arg, bool allowEmptyValue = true)
Parameters
Type Name Description
Argument<T> arg

Argument definition to configure

bool allowEmptyValue

Allow or disallow empty values

Returns
Type Description
Argument<T>

The argument

Type Parameters
Name Description
T
Exceptions
Type Condition
ArgumentNullException
| Edit this page View Source

AsNotRequired<T>(Argument<T>)

Configures an argument definition as not required

Declaration
public static Argument<T> AsNotRequired<T>(this Argument<T> arg)
Parameters
Type Name Description
Argument<T> arg

Argument definition to configure

Returns
Type Description
Argument<T>

The argument

Type Parameters
Name Description
T
Exceptions
Type Condition
ArgumentNullException
| Edit this page View Source

AsRequired<T>(Argument<T>)

Configures an argument definition as required

Declaration
public static Argument<T> AsRequired<T>(this Argument<T> arg)
Parameters
Type Name Description
Argument<T> arg

Argument definition to configure

Returns
Type Description
Argument<T>

The argument

Type Parameters
Name Description
T
Exceptions
Type Condition
ArgumentNullException
| Edit this page View Source

ExistenceOptional<T>(Argument<T>)

Configures an argument definition to not require existence. Must be a file or directory argument.

Declaration
public static Argument<T> ExistenceOptional<T>(this Argument<T> arg)
Parameters
Type Name Description
Argument<T> arg
Returns
Type Description
Argument<T>
Type Parameters
Name Description
T
Exceptions
Type Condition
ArgumentNullException
InvalidOperationException
| Edit this page View Source

FromPositionalArgument<T>(Argument<T>, int)

Gets the value from an unnamed variable based on position in the arg string.

Declaration
public static Argument<T> FromPositionalArgument<T>(this Argument<T> arg, int position)
Parameters
Type Name Description
Argument<T> arg
int position

Position in the arg string

Returns
Type Description
Argument<T>
Type Parameters
Name Description
T
| Edit this page View Source

GetBooleanValue(ArgumentCollection, string)

Get an argument value as boolean

Declaration
public static bool GetBooleanValue(this ArgumentCollection args, string argumentName)
Parameters
Type Name Description
ArgumentCollection args

Argument collection

string argumentName

Argument name

Returns
Type Description
bool

The value as boolean

Exceptions
Type Condition
InvalidOperationException
| Edit this page View Source

GetCloneOfArguments(CommandExecutionInfo, string, bool)

Declaration
public static CommandExecutionInfo GetCloneOfArguments(this CommandExecutionInfo execInfo, string commandName, bool quietMode)
Parameters
Type Name Description
CommandExecutionInfo execInfo
string commandName
bool quietMode
Returns
Type Description
CommandExecutionInfo
| Edit this page View Source

GetDateTimeValue(ArgumentCollection, string)

Get an argument value as DateTime

Declaration
public static DateTime GetDateTimeValue(this ArgumentCollection args, string argumentName)
Parameters
Type Name Description
ArgumentCollection args

Argument collection

string argumentName

Argument name

Returns
Type Description
DateTime

The value as DateTime

Exceptions
Type Condition
InvalidOperationException
| Edit this page View Source

GetInt32Value(ArgumentCollection, string)

Get an argument value as int32

Declaration
public static int GetInt32Value(this ArgumentCollection args, string argumentName)
Parameters
Type Name Description
ArgumentCollection args

Argument collection

string argumentName

Argument name

Returns
Type Description
int

The value as int

Exceptions
Type Condition
InvalidOperationException
| Edit this page View Source

GetPathToDirectory(ArgumentCollection, string, bool)

Declaration
public static string GetPathToDirectory(this ArgumentCollection arguments, string argumentName, bool mustExist = false)
Parameters
Type Name Description
ArgumentCollection arguments
string argumentName
bool mustExist
Returns
Type Description
string
| Edit this page View Source

GetPathToFile(ArgumentCollection, string, bool)

Declaration
public static string GetPathToFile(this ArgumentCollection arguments, string argumentName, bool mustExist = false)
Parameters
Type Name Description
ArgumentCollection arguments
string argumentName
bool mustExist
Returns
Type Description
string
| Edit this page View Source

GetStringValue(ArgumentCollection, string)

Get an argument value as string

Declaration
public static string GetStringValue(this ArgumentCollection args, string argumentName)
Parameters
Type Name Description
ArgumentCollection args

Argument collection

string argumentName

Argument name

Returns
Type Description
string

The value as string

Exceptions
Type Condition
InvalidOperationException
| Edit this page View Source

HasValue(ArgumentCollection, string)

Does this argument collection have a value for an argument

Declaration
public static bool HasValue(this ArgumentCollection args, string argumentName)
Parameters
Type Name Description
ArgumentCollection args

Argument collection

string argumentName

Argument name

Returns
Type Description
bool

True if there's a value

| Edit this page View Source

MustExist<T>(Argument<T>)

Configures an argument definition to require existence. Must be a file or directory argument.

Declaration
public static Argument<T> MustExist<T>(this Argument<T> arg)
Parameters
Type Name Description
Argument<T> arg
Returns
Type Description
Argument<T>
Type Parameters
Name Description
T
Exceptions
Type Condition
ArgumentNullException
InvalidOperationException
| Edit this page View Source

RemoveArgumentValue(CommandExecutionInfo, string)

Remove an argument value from the command execution info

Declaration
public static void RemoveArgumentValue(this CommandExecutionInfo execInfo, string argName)
Parameters
Type Name Description
CommandExecutionInfo execInfo

The execution information for the command

string argName

Argument name to remove

Exceptions
Type Condition
ArgumentNullException
| Edit this page View Source

WithAlias<T>(Argument<T>, string)

Adds a alias to an argument definition

Declaration
public static Argument<T> WithAlias<T>(this Argument<T> arg, string alias)
Parameters
Type Name Description
Argument<T> arg
string alias

Alternate name for the argument

Returns
Type Description
Argument<T>
Type Parameters
Name Description
T
| Edit this page View Source

WithDefaultValue<T>(Argument<T>, T)

Adds a default value for the argument definition

Declaration
public static Argument<T> WithDefaultValue<T>(this Argument<T> arg, T defaultValue)
Parameters
Type Name Description
Argument<T> arg

Argument definition to configure

T defaultValue

Default value

Returns
Type Description
Argument<T>

The argument

Type Parameters
Name Description
T
Exceptions
Type Condition
ArgumentNullException
| Edit this page View Source

WithDescription<T>(Argument<T>, string)

Adds a description to an argument definition

Declaration
public static Argument<T> WithDescription<T>(this Argument<T> arg, string description)
Parameters
Type Name Description
Argument<T> arg
string description

Human readable description for the argument

Returns
Type Description
Argument<T>
Type Parameters
Name Description
T
| Edit this page View Source

WithFriendlyName<T>(Argument<T>, string)

Adds a user friendly name to an argument definition

Declaration
public static Argument<T> WithFriendlyName<T>(this Argument<T> arg, string friendlyName)
Parameters
Type Name Description
Argument<T> arg
string friendlyName

Human readable name for the argument

Returns
Type Description
Argument<T>
Type Parameters
Name Description
T
  • Edit this page
  • View Source
In this article
Back to top Copyright © www.benday.com | info@benday.com