Show / Hide Table of Contents

Class Argument<T>

Base class for arguments

Inheritance
object
Argument<T>
BooleanArgument
DateTimeArgument
Int32Argument
StringArgument
Implements
IArgument
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 abstract class Argument<T> : IArgument
Type Parameters
Name Description
T

The data type for the argument

Constructors

| Edit this page View Source

Argument(string)

Declaration
public Argument(string name)
Parameters
Type Name Description
string name

Properties

| Edit this page View Source

Alias

The alternate name of the argument when used on the command line

Declaration
public string Alias { get; set; }
Property Value
Type Description
string
| Edit this page View Source

AllowEmptyValue

Is an empty value valid? This is more helpful for boolean arguments when the existence of the argument on the command line call indicates that something should be done.

Declaration
public bool AllowEmptyValue { get; set; }
Property Value
Type Description
bool
| Edit this page View Source

DataType

Data type for this argument

Declaration
public abstract ArgumentDataType DataType { get; }
Property Value
Type Description
ArgumentDataType
| Edit this page View Source

Description

Human readable description of this argument

Declaration
public string Description { get; set; }
Property Value
Type Description
string
| Edit this page View Source

FriendlyName

Human readable friendly name for this argument

Declaration
public string FriendlyName { get; set; }
Property Value
Type Description
string
| Edit this page View Source

HasAlias

Returns true if a command name alias is set

Declaration
public bool HasAlias { get; }
Property Value
Type Description
bool
| Edit this page View Source

HasValue

Does this argument have a value?

Declaration
public bool HasValue { get; }
Property Value
Type Description
bool
| Edit this page View Source

IsPositionalSource

Should this value come from an unnamed argument on the command line? If yes, the Alias value will be the POSITION_x.

Declaration
public bool IsPositionalSource { get; set; }
Property Value
Type Description
bool
| Edit this page View Source

IsRequired

Is this argument required to have a value in order to be valid?

Declaration
public bool IsRequired { get; set; }
Property Value
Type Description
bool
| Edit this page View Source

Name

The name of the argument when used on the command line

Declaration
public string Name { get; set; }
Property Value
Type Description
string
| Edit this page View Source

Value

The value of this argument

Declaration
public T Value { get; set; }
Property Value
Type Description
T

Methods

| Edit this page View Source

GetDefaultValue()

Get the default value for this argument for this data type

Declaration
protected abstract T GetDefaultValue()
Returns
Type Description
T
| Edit this page View Source

OnInitialize()

Template method for adding logic at the end of the initialization process

Declaration
protected virtual void OnInitialize()
| Edit this page View Source

TrySetValue(string)

Try to set the value for this argument

Declaration
public abstract bool TrySetValue(string input)
Parameters
Type Name Description
string input

String representation of the argument value

Returns
Type Description
bool

True if the value could be converted to the argument's data type and the value was set

| Edit this page View Source

Validate()

Validate this argument according to the configuration.

Declaration
public virtual bool Validate()
Returns
Type Description
bool

True if the argument is valid

Implements

IArgument

Extension Methods

ExtensionMethods.AllowEmptyValue<T>(Argument<T>, bool)
ExtensionMethods.AsNotRequired<T>(Argument<T>)
ExtensionMethods.AsRequired<T>(Argument<T>)
ExtensionMethods.ExistenceOptional<T>(Argument<T>)
ExtensionMethods.FromPositionalArgument<T>(Argument<T>, int)
ExtensionMethods.MustExist<T>(Argument<T>)
ExtensionMethods.WithAlias<T>(Argument<T>, string)
ExtensionMethods.WithDefaultValue<T>(Argument<T>, T)
ExtensionMethods.WithDescription<T>(Argument<T>, string)
ExtensionMethods.WithFriendlyName<T>(Argument<T>, string)
  • Edit this page
  • View Source
In this article
Back to top Copyright © www.benday.com | info@benday.com