public abstract record PickerResult<T> : IEquatable<PickerResult<T>> where T : IAsyncDisposable A dialog outcome. User dismissal is distinct from cancellation, unavailability and failure.
Remarks
The set of cases is closed: Selected, Dismissed, Unavailable and Failed are the only ones for this major version.
Methods
Match
public TResult Match<TResult>(Func<PickerResult<T>.Selected, TResult> selected, Func<PickerResult<T>.Dismissed, TResult> dismissed, Func<PickerResult<T>.Unavailable, TResult> unavailable, Func<PickerResult<T>.Failed, TResult> failed) Calls the function for this case and returns its result.
Type parameters
TResultThe type the functions return.
Parameters
selectedCalled with a
Selectedcase, which also carriesSelected.SelectedFilter. It owns the acquired resource: disposeSelected.Value.dismissedCalled with a
Dismissedcase.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 acquired resource of a Selected.
Parameters
valueThe acquired resource when this is a
Selected; otherwise the default. Dispose it.
Returns
true for a Selected; false for Dismissed, Unavailable and Failed.
Example
if ((await dialogs.OpenFileAsync(options)).TryGetValue(out var lease))
{
await using (lease) { … }
}