зеркало из https://github.com/github/VisualStudio.git
Decouple UI logic from backend
This commit is contained in:
Родитель
1852ed41ec
Коммит
3b1703d570
|
@ -2,32 +2,34 @@
|
|||
using System.ComponentModel.Composition;
|
||||
using System.Reactive.Linq;
|
||||
using GitHub.ViewModels;
|
||||
using Microsoft.VisualStudio.PlatformUI;
|
||||
using Octokit;
|
||||
using ReactiveUI;
|
||||
using GitHub.UI;
|
||||
|
||||
namespace GitHub.Authentication
|
||||
{
|
||||
[Export(typeof(ITwoFactorChallengeHandler))]
|
||||
public class TwoFactorChallengeHandler : ITwoFactorChallengeHandler
|
||||
{
|
||||
readonly IServiceProvider serviceProvider;
|
||||
//readonly IServiceProvider serviceProvider;
|
||||
readonly Lazy<ITwoFactorDialog> lazyTwoFactorDialog;
|
||||
|
||||
[ImportingConstructor]
|
||||
public TwoFactorChallengeHandler(IServiceProvider serviceProvider)
|
||||
public TwoFactorChallengeHandler(Lazy<ITwoFactorDialog> twoFactorDialog)
|
||||
{
|
||||
this.serviceProvider = serviceProvider;
|
||||
//this.serviceProvider = serviceProvider;
|
||||
this.lazyTwoFactorDialog = twoFactorDialog;
|
||||
}
|
||||
|
||||
public IObservable<TwoFactorChallengeResult> HandleTwoFactorException(TwoFactorRequiredException exception)
|
||||
{
|
||||
var twoFactorDialog = (TwoFactorDialogViewModel)serviceProvider.GetService(typeof(TwoFactorDialogViewModel));
|
||||
var twoFactorView = (IViewFor<TwoFactorDialogViewModel>)serviceProvider.GetService(typeof(IViewFor<TwoFactorDialogViewModel>));
|
||||
var twoFactorDialog = lazyTwoFactorDialog.Value as TwoFactorDialogViewModel;
|
||||
//var twoFactorView = (IViewFor<TwoFactorDialogViewModel>)serviceProvider.GetService(typeof(IViewFor<TwoFactorDialogViewModel>));
|
||||
|
||||
return Observable.Start(() =>
|
||||
{
|
||||
twoFactorView.ViewModel = twoFactorDialog;
|
||||
((DialogWindow)twoFactorView).Show();
|
||||
//twoFactorView.ViewModel = twoFactorDialog;
|
||||
//((DialogWindow)twoFactorView).Show();
|
||||
|
||||
var userError = new TwoFactorRequiredUserError(exception);
|
||||
return twoFactorDialog.Show(userError)
|
||||
|
@ -37,8 +39,9 @@ namespace GitHub.Authentication
|
|||
: Observable.Throw<TwoFactorChallengeResult>(exception));
|
||||
}, RxApp.MainThreadScheduler)
|
||||
.SelectMany(x => x)
|
||||
.Finally(() =>
|
||||
((DialogWindow)twoFactorView).Hide());
|
||||
//.Finally(() =>
|
||||
// ((DialogWindow)twoFactorView).Hide());
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче