A variant stores one value of either type T1 or T2. More...
Inherits IStrongBox.
Public Member Functions | |
ValueVariant (T1 value) | |
Creates a new variant from the given value . More... | |
ValueVariant (T2 value) | |
Creates a new variant from the given value . More... | |
void | Reset () |
Resets the value. More... | |
T1 | AsT1 () |
Gets the value as T1. More... | |
void | Assign (T1 value) |
Assigns the given value to this variant. More... | |
T2 | AsT2 () |
Gets the value as T2. More... | |
void | Assign (T2 value) |
Assigns the given value to this variant. More... | |
ValueVariant< O1, O2 > | ToVariant< O1, O2 > () |
Translates this variant to another variant. More... | |
Static Public Member Functions | |
static implicit | operator ValueVariant< T1, T2 > (T1 value) |
Implicitly creates a new variant from the given value . More... | |
static implicit | operator T1 (ValueVariant< T1, T2 > value) |
Implicitly converts the variant value to its T1 value. More... | |
static implicit | operator ValueVariant< T1, T2 > (T2 value) |
Implicitly creates a new variant from the given value . More... | |
static implicit | operator T2 (ValueVariant< T1, T2 > value) |
Implicitly converts the variant value to its T1 value. More... | |
Properties | |
bool | IsSet [get] |
Gets whether a value is set at all. More... | |
bool | IsT1 [get] |
Gets whether a value of type T1 is set. More... | |
bool | IsT2 [get] |
Gets whether a value of type T2 is set. More... | |
A variant stores one value of either type T1 or T2.
Value access is type safe.
T1 | First type to store. |
T2 | Second type to store. |
ValueVariant | ( | T1 | value | ) |
Creates a new variant from the given value .
value | Value to store. |
ValueVariant | ( | T2 | value | ) |
Creates a new variant from the given value .
value | Value to store. |
void Assign | ( | T1 | value | ) |
Assigns the given value to this variant.
value | Value to set. |
void Assign | ( | T2 | value | ) |
Assigns the given value to this variant.
value | Value to set. |
T1 AsT1 | ( | ) |
Gets the value as T1.
InvalidCastException | Thrown if value stored is not of type T1 |
T2 AsT2 | ( | ) |
Gets the value as T2.
InvalidCastException | Thrown if value stored is not of type T2 |
|
static |
Implicitly converts the variant value to its T1 value.
value |
|
static |
Implicitly converts the variant value to its T1 value.
value |
|
static |
Implicitly creates a new variant from the given value .
value | Value to create variant from. |
|
static |
Implicitly creates a new variant from the given value .
value | Value to create variant from. |
void Reset | ( | ) |
Resets the value.
After this call IsSet returns false
.
ValueVariant< O1, O2 > ToVariant< O1, O2 > | ( | ) |
Translates this variant to another variant.
Attention: use with care. The translations are not totally fool proof.
O1 | First target type. |
O2 | Second target type. |
|
get |
Gets whether a value is set at all.
true
if a value is set.
|
get |
Gets whether a value of type T1 is set.
true
if value is set and it is of type T1.
|
get |
Gets whether a value of type T2 is set.
true
if value is set and it is of type T2.