public TwoFactorDialogViewModel(
            IVisualStudioBrowser browser,
            ITwoFactorChallengeHandler twoFactorChallengeHandler)
        {
            Title = "Two-Factor authentication required";
            twoFactorChallengeHandler.SetViewModel(this);

            var canVerify = this.WhenAny(
                x => x.AuthenticationCode,
                x => x.IsBusy,
                (code, busy) => !string.IsNullOrEmpty(code.Value) && code.Value.Length == 6 && !busy.Value);

            OkCommand         = ReactiveCommand.Create(canVerify);
            CancelCommand     = ReactiveCommand.Create();
            NavigateLearnMore = ReactiveCommand.Create();
            NavigateLearnMore.Subscribe(x => browser.OpenUrl(GitHubUrls.TwoFactorLearnMore));
            //TODO: ShowHelpCommand.Subscribe(x => browser.OpenUrl(twoFactorHelpUri));
            ResendCodeCommand = ReactiveCommand.Create();

            showErrorMessage = this.WhenAny(
                x => x.IsAuthenticationCodeSent,
                x => x.InvalidAuthenticationCode,
                (authSent, invalid) => invalid.Value && !authSent.Value)
                               .ToProperty(this, x => x.ShowErrorMessage);

            description = this.WhenAny(x => x.TwoFactorType, x => x.Value)
                          .Select(type =>
            {
                switch (type)
                {
                case TwoFactorType.Sms:
                    return("We sent you a message via SMS with your authentication code.");

                case TwoFactorType.AuthenticatorApp:
                    return("Open the two-factor authentication app on your device to view your " +
                           "authentication code.");

                case TwoFactorType.Unknown:
                    return("Enter a login authentication code here");

                default:
                    return(null);
                }
            })
                          .ToProperty(this, x => x.Description);

            isShowing = this.WhenAny(x => x.TwoFactorType, x => x.Value)
                        .Select(factorType => factorType != TwoFactorType.None)
                        .ToProperty(this, x => x.IsShowing);

            isSms = this.WhenAny(x => x.TwoFactorType, x => x.Value)
                    .Select(factorType => factorType == TwoFactorType.Sms)
                    .ToProperty(this, x => x.IsSms);
        }
        public TwoFactorDialogViewModel(
            IVisualStudioBrowser browser,
            ITwoFactorChallengeHandler twoFactorChallengeHandler)
        {
            Title = "Two-Factor authentication required";
            twoFactorChallengeHandler.SetViewModel(this);

            var canVerify = this.WhenAny(
                x => x.AuthenticationCode,
                x => x.IsBusy,
                (code, busy) => !string.IsNullOrEmpty(code.Value) && code.Value.Length == 6 && !busy.Value);

            OkCommand = ReactiveCommand.Create(canVerify);
            CancelCommand = ReactiveCommand.Create();
            NavigateLearnMore = ReactiveCommand.Create();
            NavigateLearnMore.Subscribe(x => browser.OpenUrl(GitHubUrls.TwoFactorLearnMore));
            //TODO: ShowHelpCommand.Subscribe(x => browser.OpenUrl(twoFactorHelpUri));
            ResendCodeCommand = ReactiveCommand.Create();

            showErrorMessage = this.WhenAny(
                x => x.IsAuthenticationCodeSent,
                x => x.InvalidAuthenticationCode,
                (authSent, invalid) => invalid.Value && !authSent.Value)
                .ToProperty(this, x => x.ShowErrorMessage);

            description = this.WhenAny(x => x.TwoFactorType, x => x.Value)
                .Select(type =>
                {
                    switch (type)
                    {
                        case TwoFactorType.Sms:
                            return "We sent you a message via SMS with your authentication code.";
                        case TwoFactorType.AuthenticatorApp:
                            return "Open the two-factor authentication app on your device to view your " +
                                "authentication code.";
                        case TwoFactorType.Unknown:
                            return "Enter a login authentication code here";

                        default:
                            return null;
                    }
                })
                .ToProperty(this, x => x.Description);

            isShowing = this.WhenAny(x => x.TwoFactorType, x => x.Value)
                .Select(factorType => factorType != TwoFactorType.None)
                .ToProperty(this, x => x.IsShowing);

            isSms = this.WhenAny(x => x.TwoFactorType, x => x.Value)
                .Select(factorType => factorType == TwoFactorType.Sms)
                .ToProperty(this, x => x.IsSms);
        }