Class Argument
The Argument class is a runtime validated representation of an actual command argument and its value passed by a user or an application.
public sealed class Argument : IEquatable<Argument?>, IKeyAsId, IValue
- Inheritance
-
Argument
- Implements
- Inherited Members
Remarks
An argument id is always unique within a command. By design Argument implements the default equality IEquatable<T> and GetHashCode() using Id property. Thus, two arguments with the same id are equal irrespective of other property values. This is done to improve performance during lookup and avoid multiple arguments with same identifiers.
The arguments can have same ids across multiple commands. Each Command has ArgumentDescriptors collection that contains attributes with unique ids.
Constructors
Argument(ArgumentDescriptor, object)
Initialize a new instance..
public Argument(ArgumentDescriptor argumentDescriptor, object value)
Parameters
argumentDescriptor
ArgumentDescriptorThe argument descriptor.
value
objectThe argument value.
Properties
DataType
The option data type.
[JsonIgnore]
public string DataType { get; }
Property Value
Descriptor
The argument descriptor.
[JsonPropertyName("descriptor")]
public ArgumentDescriptor Descriptor { get; }
Property Value
Id
The argument id.
[JsonIgnore]
public string Id { get; }
Property Value
Remarks
The argument id is unique with in a command.
Value
The argument value.
[JsonPropertyName("value")]
public object Value { get; set; }
Property Value
Methods
ChangeValueType(Type)
Changes the argument value to the specified type.
public void ChangeValueType(Type type)
Parameters
type
TypeThe new type to use.
Equals(Argument?)
Indicates whether the current argument is equal to another argument.
public bool Equals(Argument? other)
Parameters
other
ArgumentThe other argument.
Returns
- bool
true
if the current argument is equal to the other argument; otherwise, false.
Equals(object?)
Indicates whether the current argument is equal to another argument.
public override bool Equals(object? obj)
Parameters
obj
objectThe other argument.
Returns
- bool
true
if the current argument is equal to the other argument; otherwise, false.
GetHashCode()
Returns the hash code for this argument.
public override int GetHashCode()
Returns
Operators
operator ==(Argument?, Argument?)
Indicates whether the current argument is equal to another argument.
public static bool operator ==(Argument? left, Argument? right)
Parameters
Returns
- bool
true
if the current argument is equal to the other argument; otherwise, false.
operator !=(Argument?, Argument?)
Indicates whether the current argument is not equal to another argument.
public static bool operator !=(Argument? left, Argument? right)
Parameters
Returns
- bool
true
if the current argument is not equal to the other argument; otherwise, false.