Class OptionalMediationExtensions
Optional request extensions
public static class OptionalMediationExtensions
- Inheritance
-
OptionalMediationExtensions
- Inherited Members
Methods
CatchAsync<TResult>(Task<Option<TResult, ApizrException<TResult>>>, Action<Exception>, bool)
Return TResult (from fetch or cache), no matter of exception (handled by onException).
Could throw if you ask to with letThrowOnExceptionWithEmptyCache in case of exception with empty cache (onException won't be called),
otherwise return the empty cache (have to be managed) after calling onException action.
public static Task<TResult> CatchAsync<TResult>(this Task<Option<TResult, ApizrException<TResult>>> option, Action<Exception> onException, bool letThrowOnExceptionWithEmptyCache = false)
Parameters
optionTask<Option<TResult, ApizrException<TResult>>>onExceptionAction<Exception>Action to call to handle exception (like informing the user) before returning result from cache
letThrowOnExceptionWithEmptyCacheboolTrue to let it throw the inner exception in case of empty cache, False to handle it with
onExceptionaction and return empty cache result
Returns
- Task<TResult>
Type Parameters
TResultThe returned result (from fetch if succeed or cache if failed)
OnResultAsync<TResult>(Task<Option<TResult, ApizrException<TResult>>>, Action<TResult>)
The action will be invoked just before throwing any exception that might have occurred during request execution
public static Task OnResultAsync<TResult>(this Task<Option<TResult, ApizrException<TResult>>> option, Action<TResult> onResult)
Parameters
optionTask<Option<TResult, ApizrException<TResult>>>onResultAction<TResult>The action to invoke
Returns
Type Parameters
TResultThe returned result (from fetch if succeed or cache if failed)
OnResultAsync<TResult>(Task<Option<TResult, ApizrException<TResult>>>, Func<TResult, ApizrException<TResult>, bool>)
The function will be invoked with the returned result and potential occurred exception. You might decide to throw from the function itself, or to return the success boolean.
public static Task<bool> OnResultAsync<TResult>(this Task<Option<TResult, ApizrException<TResult>>> option, Func<TResult, ApizrException<TResult>, bool> onResult)
Parameters
optionTask<Option<TResult, ApizrException<TResult>>>onResultFunc<TResult, ApizrException<TResult>, bool>The function to invoke
Returns
Type Parameters
TResultThe returned result (from fetch if succeed or cache if failed)
OnResultAsync<TResult>(Task<Option<TResult, ApizrException<TResult>>>, Func<TResult, ApizrException<TResult>, Task<bool>>)
The function will be invoked with the returned result and potential occurred exception. Checking exception, you might decide to throw it from the function itself, or to return the success boolean.
public static Task<bool> OnResultAsync<TResult>(this Task<Option<TResult, ApizrException<TResult>>> option, Func<TResult, ApizrException<TResult>, Task<bool>> onResult)
Parameters
optionTask<Option<TResult, ApizrException<TResult>>>onResultFunc<TResult, ApizrException<TResult>, Task<bool>>The function to invoke
Returns
Type Parameters
TResultThe returned result (from fetch if succeed or cache if failed)