internal static IObservable <T> CatchAndLog <T>( this IObservable <T> This, IExceptionHandlerService ExceptionService, Func <IObservable <T> > handledResult) { return(This.Catch((Exception exc) => { if (!ExceptionService.LogException(exc)) { return Observable.Throw <T>(exc); } return handledResult(); })); }
public static IObservable <bool> CheckLocationPermission ( this ICheckPermissionProvider permissionProvider, IExceptionHandlerService exceptionHandler ) => permissionProvider .Location .Select(result => { if (!result) { exceptionHandler.LogException(new LocationActivationException(ActivationFailedReasons.PermissionsIssue)); return(false); } return(true); });
private IObservable <LocationRecorded> createPositionChanged() { return (Observable.Defer(() => _permissionProvider .CheckLocationPermission(_exceptionHandling) .SelectMany(_ => CreateStartLocationUpdates() ) ) .Catch((Exception exc) => { _exceptionHandling.LogException(exc); return Observable.Throw <LocationRecorded>(exc); }) .Repeat() .Log("PreRefCount:ActiveListener") .Publish() .RefCount() .Log("RefCount:ActiveListener")); }