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 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 Status |
Success
: bool
[Get] | |
Value
: TValue
[Get] |
The value of the result.
Signature
TValue Value |
Equals
(
other
)
|
Signature
bool Equals(OVRResult< TStatus > other) |
Equals
(
obj
)
|
Determines whether the current OVRResult<TStatus> is equal to another object.
Signature
override bool Equals(object obj) Parameters |
Equals
(
other
)
|
Signature
bool Equals(OVRResult< TValue, TStatus > other) Parameters |
Equals
(
obj
)
| |
Equals
()
|
Signature
override bool TStatus other && Equals(other) Parameters otherReturns override bool TStatus other && |
GetHashCode
()
|
Gets a hashcode suitable for use in a Dictionary or HashSet.
Signature
override int 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 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 ToString() |
ToString
()
|
Generates a string representation of this result object.
Signature
override string 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 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 > 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 > 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 > 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 > 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 > 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.
|
operator bool
(
value
)
|
Implicitly casts an OVRResult to a bool.
If the OVRResult represents success, then it will convert to true. Otherwise, it will convert to false.
For example, this allows you to write code like:
var result = DoOperation();
if (result) {
Debug.Log("Operation succeeded.");
} else {
Debug.LogError($"Operation failed with error {result.Status}.");
}
Signature
static implicit operator bool(OVRResult< TStatus > value) |
operator bool
(
value
)
|
Implicitly casts an OVRResult to a bool.
If the OVRResult represents success, then it will convert to true. Otherwise, it will convert to false.
For example, this allows you to write code like:
var result = DoOperation();
if (result) {
Debug.Log("Operation succeeded.");
} else {
Debug.LogError($"Operation failed with error {result.Status}.");
}
Signature
static implicit operator bool(OVRResult< TValue, TStatus > value) |