public IObservable <RecoveryOptionResult> Show(UserError userError) { IsBusy = false; var error = userError as TwoFactorRequiredUserError; Debug.Assert(error != null, String.Format(CultureInfo.InvariantCulture, "The user error is '{0}' not a TwoFactorRequiredUserError", userError)); InvalidAuthenticationCode = error.RetryFailed; TwoFactorType = error.TwoFactorType; var ok = OkCommand .Do(_ => IsBusy = true) .Select(_ => AuthenticationCode == null ? RecoveryOptionResult.CancelOperation : RecoveryOptionResult.RetryOperation) .Do(_ => error.ChallengeResult = AuthenticationCode != null ? new TwoFactorChallengeResult(AuthenticationCode) : null); var resend = ResendCodeCommand.Select(_ => RecoveryOptionResult.RetryOperation) .Do(_ => error.ChallengeResult = TwoFactorChallengeResult.RequestResendCode); var cancel = CancelCommand.Select(_ => RecoveryOptionResult.CancelOperation); return(Observable.Merge(ok, cancel, resend) .Take(1) .Do(_ => IsAuthenticationCodeSent = error.ChallengeResult == TwoFactorChallengeResult.RequestResendCode)); }