public abstract record PlatformResult<T> : IEquatable<PlatformResult<T>> A service outcome. Cancellation is represented by an OperationCanceledException.
Remarks
The set of cases is closed: Success, Unavailable and Failed are the only ones for this major version.
Properties
Methods
Match
public TResult Match<TResult>(Func<T, TResult> success, Func<PlatformResult<T>.Unavailable, TResult> unavailable, Func<PlatformResult<T>.Failed, TResult> failed) Calls the function for this case and returns its result.
Type parameters
TResultThe type the functions return.
Parameters
successCalled with the value of a
Success.unavailableCalled with an
Unavailablecase.failedCalled with a
Failedcase.
Returns
What the called function returned.
Exceptions
ArgumentNullExceptionA function is
null.
TryGetValue
public bool TryGetValue(out T value) Gets the value of a Success.
Parameters
valueThe returned value when this is a
Success; otherwise the default.
Returns
true for a Success; false for Unavailable and Failed.
Example
if ((await store.ReadAsync(key)).TryGetValue(out var secret)) { … }