Struct GivenParameter<T>
This class describes a parameter that is optional. Whether or not it was specified can be found using the Given variable. It also has a default value when not specified.
Inherited Members
Namespace: SpiceSharp
Assembly: SpiceSharp.dll
Syntax
public readonly struct GivenParameter<T> : IEquatable<T>, IEquatable<GivenParameter<T>>
Type Parameters
Name | Description |
---|---|
T | The base value type. |
Remarks
This class is related to nullable types, but instead of assigning/returning null, we still want these parameters to return a default value.
Constructors
GivenParameter(T, bool)
Initializes a new instance of the GivenParameter<T> class.
Declaration
public GivenParameter(T value, bool given = true)
Parameters
Type | Name | Description |
---|---|---|
T | value | |
bool | given |
Properties
Given
Gets whether or not the parameter was specified by the user.
Declaration
public bool Given { get; }
Property Value
Type | Description |
---|---|
bool | Whether or not the parameter is given. |
Value
Gets or sets the value of the parameter.
Declaration
public T Value { get; }
Property Value
Type | Description |
---|---|
T | The value of the parameter. |
Methods
Equals(GivenParameter<T>)
Determines whether the specified value is equal to this instance.
Declaration
public bool Equals(GivenParameter<T> value)
Parameters
Type | Name | Description |
---|---|---|
GivenParameter<T> | value | The value. |
Returns
Type | Description |
---|---|
bool |
|
Equals(object)
Determines whether the specified object, is equal to this instance.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with this instance. |
Returns
Type | Description |
---|---|
bool |
|
Overrides
Equals(T)
Determines whether the specified value is equal to this instance.
Declaration
public bool Equals(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value. |
Returns
Type | Description |
---|---|
bool |
|
GetHashCode()
Returns a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
Remarks
The hash code is not based on whether or not the value is given.
ToString()
Returns a string that represents this instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string that represents this instance. |
Overrides
Operators
operator ==(GivenParameter<T>, GivenParameter<T>)
Implements the operator ==.
Declaration
public static bool operator ==(GivenParameter<T> left, GivenParameter<T> right)
Parameters
Type | Name | Description |
---|---|---|
GivenParameter<T> | left | The left argument. |
GivenParameter<T> | right | The right argument. |
Returns
Type | Description |
---|---|
bool | The result of the operator. |
implicit operator T(GivenParameter<T>)
Performs an implicit conversion from GivenParameter<T> to the base value type.
Declaration
public static implicit operator T(GivenParameter<T> parameter)
Parameters
Type | Name | Description |
---|---|---|
GivenParameter<T> | parameter | The parameter. |
Returns
Type | Description |
---|---|
T | The result of the conversion. |
implicit operator GivenParameter<T>(T)
Performs an implicit conversion from the base value type to GivenParameter<T>.
Declaration
public static implicit operator GivenParameter<T>(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The value. |
Returns
Type | Description |
---|---|
GivenParameter<T> | The result of the conversion. |
operator !=(GivenParameter<T>, GivenParameter<T>)
Implements the operator !=.
Declaration
public static bool operator !=(GivenParameter<T> left, GivenParameter<T> right)
Parameters
Type | Name | Description |
---|---|---|
GivenParameter<T> | left | The left argument. |
GivenParameter<T> | right | The right argument. |
Returns
Type | Description |
---|---|
bool | The result of the operator. |