PickerResult<T> record

Namespace Runic.Platform in Runic.Platform 0.23.0

public abstract record PickerResult<T> : IEquatable<PickerResult<T>> where T : IAsyncDisposable

Inherits or implements IEquatable.

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

TResult

The type the functions return.

Parameters

selected

Called with a Selected case, which also carries Selected.SelectedFilter. It owns the acquired resource: dispose Selected.Value.

dismissed

Called with a Dismissed case.

unavailable

Called with an Unavailable case.

failed

Called with a Failed case.

Returns

What the called function returned.

Exceptions

ArgumentNullException

A function is null.

TryGetValue

public bool TryGetValue(out T value)

Gets the acquired resource of a Selected.

Parameters

value

The 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) { … }
}