Table of Contents

Class OptionObservableExtensions

Namespace
DynamicData.Kernel
Assembly
DynamicData.dll

Extensions for optional.

public static class OptionObservableExtensions
Inheritance
OptionObservableExtensions

Methods

ConvertOr<TSource, TDestination>(IObservable<Optional<TSource>>, Func<TSource, TDestination?>, Func<TDestination?>)

Converts an observable of optional into an observable of TDestination by applying converter to convert Optionals with a value and using fallbackConverter to generate a value for those that don't have a value.

public static IObservable<TDestination?> ConvertOr<TSource, TDestination>(this IObservable<Optional<TSource>> source, Func<TSource, TDestination?> converter, Func<TDestination?> fallbackConverter) where TSource : notnull

Parameters

source IObservable<Optional<TSource>>

The source.

converter Func<TSource, TDestination>

The converter.

fallbackConverter Func<TDestination>

The fallback converter.

Returns

IObservable<TDestination>

Observable of TDestination.

Type Parameters

TSource

The type of the source.

TDestination

The type of the destination.

Exceptions

ArgumentNullException

source or converter or fallbackConverter.

Convert<TSource, TDestination>(IObservable<Optional<TSource>>, Func<TSource, Optional<TDestination>>)

Overload of Convert<TSource, TDestination>(IObservable<Optional<TSource>>, Func<TSource, TDestination>) that allows the conversion operation to also return an Optional.

public static IObservable<Optional<TDestination>> Convert<TSource, TDestination>(this IObservable<Optional<TSource>> source, Func<TSource, Optional<TDestination>> converter) where TSource : notnull where TDestination : notnull

Parameters

source IObservable<Optional<TSource>>

The source.

converter Func<TSource, Optional<TDestination>>

The converter that returns an optional value.

Returns

IObservable<Optional<TDestination>>

Observable Optional of TDestination.

Type Parameters

TSource

The type of the source.

TDestination

The type of the destination.

Remarks

Exceptions

ArgumentNullException

Source or Converter was null.

Convert<TSource, TDestination>(IObservable<Optional<TSource>>, Func<TSource, TDestination>)

Converts an Observable Optional of TSource into an Observable Optional of TDestination by applying the conversion function to those Optionals that have a value.

public static IObservable<Optional<TDestination>> Convert<TSource, TDestination>(this IObservable<Optional<TSource>> source, Func<TSource, TDestination> converter) where TSource : notnull where TDestination : notnull

Parameters

source IObservable<Optional<TSource>>

The source.

converter Func<TSource, TDestination>

The converter.

Returns

IObservable<Optional<TDestination>>

Observable Optional of TDestination.

Type Parameters

TSource

The type of the source.

TDestination

The type of the destination.

Remarks

Exceptions

ArgumentNullException

Source or Converter was null.

OnHasNoValue<T>(IObservable<Optional<T>>, Action, Action<T>?)

Pass-Thru operator that invokes the specified action for Optionals without a value (or, if provided, the else Action for those with a value).

public static IObservable<Optional<T>> OnHasNoValue<T>(this IObservable<Optional<T>> source, Action action, Action<T>? elseAction = null) where T : notnull

Parameters

source IObservable<Optional<T>>

The source.

action Action

The action.

elseAction Action<T>

Optional alternative action for the Else case.

Returns

IObservable<Optional<T>>

The same Observable Optional.

Type Parameters

T

The type of the item.

OnHasValue<T>(IObservable<Optional<T>>, Action<T>, Action?)

Pass-Thru operator that invokes the specified action for Optionals with a value (or, if provided, the else Action for those without a value).

public static IObservable<Optional<T>> OnHasValue<T>(this IObservable<Optional<T>> source, Action<T> action, Action? elseAction = null) where T : notnull

Parameters

source IObservable<Optional<T>>

The source.

action Action<T>

The action.

elseAction Action

Optional alternative action for the Else case.

Returns

IObservable<Optional<T>>

The same Observable Optional.

Type Parameters

T

The type of the item.

Remarks

OrElse<T>(IObservable<Optional<T>>, Func<Optional<T>>)

Observable Optional operator that provides a way to (possibly) create a value for those Optionals that don't already have one.

public static IObservable<Optional<T>> OrElse<T>(this IObservable<Optional<T>> source, Func<Optional<T>> fallbackOperation) where T : notnull

Parameters

source IObservable<Optional<T>>

The source.

fallbackOperation Func<Optional<T>>

The fallback operation.

Returns

IObservable<Optional<T>>

An Observable Optional that contains the Optionals with Values or the results of the fallback operation.

Type Parameters

T

The type of the source.

Remarks

Exceptions

ArgumentNullException

source or fallbackOperation.

SelectValues<T>(IObservable<Optional<T>>)

Converts an Observable of Optional<T> into an IObservable of T by extracting the values from Optionals that have one.

public static IObservable<T> SelectValues<T>(this IObservable<Optional<T>> source) where T : notnull

Parameters

source IObservable<Optional<T>>

The source.

Returns

IObservable<T>

An Observable with the Values.

Type Parameters

T

The type of item.

Remarks

ValueOrDefault<T>(IObservable<Optional<T>>)

Returns the value if the optional has a value, otherwise returns the default value of T.

public static IObservable<T?> ValueOrDefault<T>(this IObservable<Optional<T>> source) where T : notnull

Parameters

source IObservable<Optional<T>>

The source.

Returns

IObservable<T>

The value or default.

Type Parameters

T

The type of the item.

Remarks

Observable version of ValueOrDefault<T>(in Optional<T>).

ValueOrThrow<T>(IObservable<Optional<T>>, Func<Exception>)

Converts an Observable of Optional<T> into an IObservable of T by extracting the values. If it has no value, exceptionGenerator is used to generate an exception that is injected into the stream as error.

public static IObservable<T> ValueOrThrow<T>(this IObservable<Optional<T>> source, Func<Exception> exceptionGenerator) where T : notnull

Parameters

source IObservable<Optional<T>>

The source.

exceptionGenerator Func<Exception>

The exception generator.

Returns

IObservable<T>

The value.

Type Parameters

T

The type of the item.

Remarks

Exceptions

ArgumentNullException

exceptionGenerator.

ValueOr<T>(IObservable<Optional<T>>, Func<T>)

Converts an Observable of Optional<T> into an IObservable of T by extracting the values from the ones that contain a value and then using valueSelector to generate a value for the others.

public static IObservable<T> ValueOr<T>(this IObservable<Optional<T>> source, Func<T> valueSelector) where T : notnull

Parameters

source IObservable<Optional<T>>

The source.

valueSelector Func<T>

The value selector.

Returns

IObservable<T>

If the value or a provided default.

Type Parameters

T

The type of the item.

Remarks

Observable version of ValueOr<T>(in Optional<T>, Func<T>).

Exceptions

ArgumentNullException

valueSelector.