Table of Contents

Class ParameterBase<TParameter>

Namespace
TechnologySolutions.Rfid.AsciiProtocol.Parameters
Assembly
TechnologySolutions.Rfid.AsciiProtocol.Core.dll

Base class for parameters

public abstract class ParameterBase<TParameter> : IParameterAndValue<TParameter>, IParameterValue<TParameter>, ICommandParameter, IParameterAction

Type Parameters

TParameter

The value type for the parameter

Inheritance
ParameterBase<TParameter>
Implements
IParameterAndValue<TParameter>
IParameterValue<TParameter>
Derived
Inherited Members

Constructors

ParameterBase(string)

Initializes a new instance of the ParameterBase class

protected ParameterBase(string identifier)

Parameters

identifier string

The character(s) that identify the parameter on the command line

Properties

ParameterFormat

Gets or sets the format string to write this parameter to the command line. By default this is " -{0}{1}" to insert the switch followed by ParameterIdentifier then Value

public string ParameterFormat { get; set; }

Property Value

string

ParameterIdentifier

Gets the character(s) that identify this parameter on the command line (e.g. "qs" for "-qs" query select)

public string ParameterIdentifier { get; }

Property Value

string

ParameterType

Gets the type of the ParameterValue

public Type ParameterType { get; }

Property Value

Type

ParameterValue

Gets or sets the current value of the parameter

public object ParameterValue { get; set; }

Property Value

object

Value

Gets or sets the current value of the parameter

public TParameter Value { get; set; }

Property Value

TParameter

Remarks

Override CheckValue(TParameter) and throw an ArgumentOutOrRangeException to ensure it is set to a correct value

Methods

AppendToCommandLine(StringBuilder)

Appends the parameter to the command line if the current value is not null

public virtual void AppendToCommandLine(StringBuilder line)

Parameters

line StringBuilder

The builder for the command line

CheckValue(TParameter)

When overridden in derived classes should check that the value is appropriate. Called when the Value property is assigned.

protected virtual TParameter CheckValue(TParameter value)

Parameters

value TParameter

The new value

Returns

TParameter

The value to assign to the property

Exceptions

ArgumentOutOfRangeException

If the value is out of range or accepted values

ParseParameter(string)

Parse the string to extract the parameter value

public bool ParseParameter(string parameter)

Parameters

parameter string

The parameter to parse

Returns

bool

True if the parameter is for this instance and the value was parsed successfully. False otherwise

Exceptions

ArgumentOutOfRangeException

If the value is outside the permitted range

FormatException

If the parameter is not in the expected format

ParseValue(string)

Attempt to parse the value from the command line and assign value to the parsed value

protected abstract void ParseValue(string value)

Parameters

value string

The value to parse

Exceptions

ArgumentOutOfRangeException

If the value is outside the permitted range

FormatException

If the parameter is not in the expected format

Reset()

Resets the parameter to not specified

public void Reset()