Table of Contents

Class OptionPropertyBase

Namespace
Ubiquity.CommandLineParsing
Assembly
Ubiquity.CommandlineParsing.dll

Abstract base class for implementing IOptionProperty.

public abstract class OptionPropertyBase : IOptionProperty
Inheritance
OptionPropertyBase
Implements
Inherited Members
Extension Methods

Constructors

OptionPropertyBase(CommandLineOption, bool, bool, bool)

Initializes a new instance of the OptionPropertyBase class.

protected OptionPropertyBase(CommandLineOption option, bool allowSpaceDelimitedValue, bool isCollection, bool requiresValue)

Parameters

option CommandLineOption

Option this property is for.

allowSpaceDelimitedValue bool

Flag indicating if this property allows a space delimited value.

isCollection bool

Flag to indicate if the property is a collection.

requiresValue bool

Flag to indicate if the property requires a value.

Properties

AllowSpaceDelimitedValue

Gets a value indicating whether this property allows a space delimited value.

public bool AllowSpaceDelimitedValue { get; }

Property Value

bool

Remarks

The parser, intentionally, doesn't have knowledge of the semantics of an application's choices for using a space as the delimiter between an option and it's value. This property informs the binder if it is allowed to consume an immediately following CommandLineValue as the value for this option. The implementation of, IOptionPropertyProvider normally retrieves this information from the AllowSpaceDelimitedValue attribute attached to the property this IOptionProperty represents though it can use whatever means is appropriate to the provider.

IsCollection

Gets a value indicating whether this property is a collection that accepts multiple values.

public bool IsCollection { get; }

Property Value

bool

IsSet

Gets a value indicating whether this property was set.

public bool IsSet { get; }

Property Value

bool

Remarks

If IsCollection is true then this must always be false. Otherwise, this is false until the first call to BindValue, after which it remains true. This is used to prevent setting the value multiple times.

Option

Gets the option to bind to this property.

public CommandLineOption Option { get; }

Property Value

CommandLineOption

RequiresValue

Gets a value indicating whether this property requires a value.

public bool RequiresValue { get; }

Property Value

bool

Remarks

Most options require a value, though simple booleans don't as the presence or absence of the option are enough to determine the value.

Methods

BindValue()

Sets the value of the property from Option.

public void BindValue()

BindValue(string)

Sets a value for the property when the option didn't have a value.

public void BindValue(string newValue)

Parameters

newValue string

New value for the property.

Exceptions

InvalidOperationException

If the Value is non-null or AllowSpaceDelimitedValue is false.

InternalSetValue(string?)

Abstract method to actually set the value of the property.

protected abstract void InternalSetValue(string? value)

Parameters

value string

value to set on the property.

Remarks

Implementations should handle value conversion to the proper target type via a Type converter. This includes converting to the element type of a generic collection.