enum but with some additional machinery to test for success and to distinguish between a real value and a default-initialized value. This is important because an enum constant of zero is often used to indicate Success.
true), then you can access the value using the Value property.
false), then the OVRResult does not have a value, and it is an error to access the Value property. In this case, the Status property will contain an error code.
HasValue
: bool
[Get] |
Indicates whether the result has a value.
It is an error to access Value when this property is false.
Signature
bool OVRResult< TValue, TStatus >.HasValue |
Status
: TStatus
[Get] |
The status of the result.
The status could represent success (see Success) or a failure. If it is a failure, use this property to obtain more detailed error information.
Signature
TStatus OVRResult< TValue, TStatus >::Status |
Success
: bool
[Get] | |
Value
: TValue
[Get] |
The value of the result.
Signature
TValue OVRResult< TValue, TStatus >.Value |
Equals
(
other
)
|
Signature
bool OVRResult< TValue, TStatus >.Equals(OVRResult< TStatus > other) |
Equals
(
obj
)
|
Determines whether the current OVRResult<TStatus> is equal to another object.
Signature
override bool OVRResult< TValue, TStatus >.Equals(object obj) Parameters |
Equals
(
other
)
|
Signature
bool OVRResult< TValue, TStatus >.Equals(OVRResult< TValue, TStatus > other) Parameters |
Equals
(
obj
)
| |
Equals
()
|
Signature
override bool TStatus other && OVRResult< TValue, TStatus >.Equals(other) Parameters otherReturns override bool TStatus other && |
GetHashCode
()
|
Gets a hashcode suitable for use in a Dictionary or HashSet.
Signature
override int OVRResult< TValue, TStatus >.GetHashCode() Returns override int
Returns a hashcode suitable for use in a Dictionary or HashSet.
|
GetHashCode
()
|
Gets a hashcode suitable for use in a Dictionary or HashSet.
Signature
override int OVRResult< TValue, TStatus >.GetHashCode() Returns override int
Returns a hashcode for this result.
|
ToString
()
|
Generates a string representation of this result object.
The string representation is the stringification of Status, or "(invalid result)" if this result object has not been initialized.
Signature
override string OVRResult< TValue, TStatus >.ToString() |
ToString
()
|
Generates a string representation of this result object.
Signature
override string OVRResult< TValue, TStatus >.ToString() |
TryGetValue
(
value
)
|
Tries to retrieve the value of the result.
This provides an exception-free method of obtaining the result's Value if one is available.
This allows you to simplify your code. Instead of this:
if (result.HasValue) {
var value = result.Value;
// use value
}
You can instead combine the HasValue check with the extraction of the result:
if (result.TryGetValue(out var value)) {
// use value
}
Signature
bool OVRResult< TValue, TStatus >.TryGetValue(out TValue value) Parameters value: out TValue
When this method returns, contains the value of the result if the result was successful; otherwise, the default value.
Returns bool
Returns true if the result was successful and the value is retrieved; otherwise, false.
|
From
(
status
)
| |
From
(
value
, status
)
|
Creates a new OVRResult<TValue, TStatus> with the specified value and status.
Signature
static OVRResult< TValue, TStatus > OVRResult< TValue, TStatus >.From(TValue value, TStatus status) Parameters value: TValue
The value.
status: TStatus
The status.
|
FromFailure
(
status
)
|
Creates a new OVRResult<TStatus> with the specified failure status.
Signature
static OVRResult< TStatus > OVRResult< TValue, TStatus >.FromFailure(TStatus status) Parameters status: TStatus
The status (must be a valid failure status).
Throws ArgumentException
Thrown when status is not a valid failure status.
|
FromFailure
(
status
)
|
Creates a new OVRResult<TValue, TStatus> with the specified failure status.
Signature
static OVRResult< TValue, TStatus > OVRResult< TValue, TStatus >.FromFailure(TStatus status) Parameters status: TStatus
The status (must be a valid failure status).
Returns OVRResult< TValue, TStatus >
Returns a new OVRResult<TValue, TStatus> with the specified status.
Throws ArgumentException
Thrown when status is not a valid failure status.
|
FromSuccess
(
status
)
|
Creates a new OVRResult<TStatus> with the specified success status.
Signature
static OVRResult< TStatus > OVRResult< TValue, TStatus >.FromSuccess(TStatus status) Parameters status: TStatus
The status (must be a valid success status).
Throws ArgumentException
Thrown when status is not a valid success status.
|
FromSuccess
(
value
, status
)
|
Creates a new OVRResult<TValue, TStatus> with the specified value and a success status.
Signature
static OVRResult< TValue, TStatus > OVRResult< TValue, TStatus >.FromSuccess(TValue value, TStatus status) Parameters value: TValue
The value.
status: TStatus
The status (must be a valid success status).
Returns OVRResult< TValue, TStatus >
Returns a new OVRResult<TValue, TStatus> with the specified value and status.
Throws ArgumentException
Thrown when status is not a valid success status.
|