Table of Contents

Class Option

Namespace
OneImlx.Terminal.Commands
Assembly
OneImlx.Terminal.dll

The Option class is a runtime validated representation of an actual command option and its value passed by a user or an application.

public sealed class Option : IEquatable<Option?>, IValue
Inheritance
Option
Implements
Inherited Members

Remarks

An option id is always unique within a command. By design Option implements the default equality IEquatable<T> and GetHashCode() using Id property. Thus, two options with the same id are equal irrespective of other property values. This is done to improve performance during lookup and avoid multiple options with same identifiers.

The options can have same ids across multiple commands. Each Command has OptionDescriptors collection that contains options with unique ids.

Constructors

Option(OptionDescriptor, object)

Initialize a new instance..

[JsonConstructor]
public Option(OptionDescriptor optionDescriptor, object value)

Parameters

optionDescriptor OptionDescriptor

The option descriptor.

value object

The option value.

Properties

Alias

The option alias.

[JsonIgnore]
public string? Alias { get; }

Property Value

string

DataType

The option data type.

[JsonIgnore]
public string DataType { get; }

Property Value

string

Description

The option description.

[JsonIgnore]
public string? Description { get; }

Property Value

string

Descriptor

The option descriptor.

[JsonPropertyName("descriptor")]
public OptionDescriptor Descriptor { get; }

Property Value

OptionDescriptor

Id

The option id.

[JsonIgnore]
public string Id { get; }

Property Value

string

Remarks

The option id is unique with in a command.

Value

The option value.

[JsonPropertyName("value")]
public object Value { get; set; }

Property Value

object

Methods

ChangeValueType(Type)

Changes the option value to the specified type.

public void ChangeValueType(Type type)

Parameters

type Type

The new type to use.

Equals(Option?)

Indicates whether the current option is equal to another option.

public bool Equals(Option? other)

Parameters

other Option

The other option.

Returns

bool

true if the current option is equal to the other option; otherwise, false.

Equals(object?)

Indicates whether the current option is equal to another option.

public override bool Equals(object? obj)

Parameters

obj object

The other option.

Returns

bool

true if the current option is equal to the other option; otherwise, false.

GetHashCode()

Returns the hash code for this option.

public override int GetHashCode()

Returns

int

Operators

operator ==(Option?, Option?)

Indicates whether the current option is equal to another option.

public static bool operator ==(Option? left, Option? right)

Parameters

left Option

The left option.

right Option

The right option.

Returns

bool

true if the current option is equal to the other option; otherwise, false.

operator !=(Option?, Option?)

Indicates whether the current option is not equal to another option.

public static bool operator !=(Option? left, Option? right)

Parameters

left Option

The left option.

right Option

The right option.

Returns

bool

true if the current option is not equal to the other option; otherwise, false.

See Also