зеркало из https://github.com/github/VisualStudio.git
Fix exporting of views
This commit is contained in:
Родитель
2e52a3ff10
Коммит
dd120a49bd
|
@ -32,7 +32,7 @@ namespace GitHub.Controllers
|
|||
{
|
||||
this.factory = factory;
|
||||
|
||||
machine = new StateMachine<UIViewType, Trigger>(UIViewType.Start);
|
||||
machine = new StateMachine<UIViewType, Trigger>(UIViewType.None);
|
||||
|
||||
machine.Configure(UIViewType.None)
|
||||
.Permit(Trigger.Auth, UIViewType.Login)
|
||||
|
@ -44,9 +44,9 @@ namespace GitHub.Controllers
|
|||
machine.Configure(UIViewType.Login)
|
||||
.OnEntry(() =>
|
||||
{
|
||||
var disposable = factory.GetViewModel(UIViewType.Login);
|
||||
disposables.Add(disposable);
|
||||
var viewModel = disposable.Value as ILoginViewModel;
|
||||
var dvm = factory.GetViewModel(UIViewType.Login);
|
||||
disposables.Add(dvm);
|
||||
var viewModel = dvm.Value as ILoginViewModel;
|
||||
|
||||
viewModel.AuthenticationResults.Subscribe(result =>
|
||||
{
|
||||
|
@ -54,12 +54,12 @@ namespace GitHub.Controllers
|
|||
Fire(Trigger.Next);
|
||||
});
|
||||
|
||||
disposable = factory.GetView(UIViewType.Login);
|
||||
disposables.Add(disposable);
|
||||
var view = disposable.Value;
|
||||
var dv = factory.GetView(UIViewType.Login);
|
||||
disposables.Add(dv);
|
||||
var view = dv.Value;
|
||||
view.ViewModel = viewModel;
|
||||
|
||||
var twofa = factory.GetViewModel(UIViewType.TwoFactor).Value;
|
||||
var twofa = factory.GetViewModel(UIViewType.TwoFactor).Value as ITwoFactorViewModel;
|
||||
twofa.WhenAny(x => x.IsShowing, x => x.Value)
|
||||
.Where(x => x)
|
||||
.Subscribe(_ =>
|
||||
|
@ -85,6 +85,7 @@ namespace GitHub.Controllers
|
|||
machine.Configure(UIViewType.Create)
|
||||
.OnEntry(() =>
|
||||
{
|
||||
var view = SetupView(UIViewType.Create);
|
||||
transition.OnNext(view);
|
||||
})
|
||||
.Permit(Trigger.Next, UIViewType.End);
|
||||
|
@ -103,20 +104,18 @@ namespace GitHub.Controllers
|
|||
transition.OnCompleted();
|
||||
transition.Dispose();
|
||||
})
|
||||
.Permit(Trigger.Next, UIViewType.Start);
|
||||
.Permit(Trigger.Next, UIViewType.None);
|
||||
}
|
||||
|
||||
IViewFor SetupView(UIViewType viewType)
|
||||
IView SetupView(UIViewType viewType)
|
||||
{
|
||||
IViewModel disposable;
|
||||
|
||||
disposable = factory.GetViewModel(viewType);
|
||||
disposables.Add(disposable);
|
||||
var viewModel = disposable.Value;
|
||||
var dvm = factory.GetViewModel(viewType);
|
||||
disposables.Add(dvm);
|
||||
var viewModel = dvm.Value;
|
||||
|
||||
disposable = factory.GetView(viewType);
|
||||
disposables.Add(disposable);
|
||||
var view = disposable.Value;
|
||||
var dv = factory.GetView(viewType);
|
||||
disposables.Add(dv);
|
||||
var view = dv.Value;
|
||||
|
||||
view.ViewModel = viewModel;
|
||||
return view;
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace GitHub.VisualStudio.UI.Views.Controls
|
|||
/// Interaction logic for CloneRepoControl.xaml
|
||||
/// </summary>
|
||||
[ExportView(ViewType=UIViewType.Clone)]
|
||||
public partial class CloneRepoControl : IViewFor<ICloneRepoViewModel>
|
||||
public partial class CloneRepoControl : IViewFor<ICloneRepoViewModel>, IView
|
||||
{
|
||||
public CloneRepoControl()
|
||||
{
|
||||
|
@ -32,11 +32,16 @@ namespace GitHub.VisualStudio.UI.Views.Controls
|
|||
set { ViewModel = (ICloneRepoViewModel)value; }
|
||||
}
|
||||
|
||||
object IView.ViewModel
|
||||
{
|
||||
get { return ViewModel; }
|
||||
set { ViewModel = (ICloneRepoViewModel)value; }
|
||||
}
|
||||
|
||||
public ICloneRepoViewModel ViewModel
|
||||
{
|
||||
[return: AllowNull]
|
||||
get
|
||||
{ return (ICloneRepoViewModel)GetValue(ViewModelProperty); }
|
||||
get { return (ICloneRepoViewModel)GetValue(ViewModelProperty); }
|
||||
set { SetValue(ViewModelProperty, value); }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace GitHub.VisualStudio.UI.Views.Controls
|
|||
/// Interaction logic for CloneRepoControl.xaml
|
||||
/// </summary>
|
||||
[ExportView(ViewType=UIViewType.Create)]
|
||||
public partial class CreateRepoControl : IViewFor<ICreateRepoViewModel>
|
||||
public partial class CreateRepoControl : IViewFor<ICreateRepoViewModel>, IView
|
||||
{
|
||||
public CreateRepoControl()
|
||||
{
|
||||
|
@ -75,6 +75,12 @@ namespace GitHub.VisualStudio.UI.Views.Controls
|
|||
set { ViewModel = (ICreateRepoViewModel)value; }
|
||||
}
|
||||
|
||||
object IView.ViewModel
|
||||
{
|
||||
get { return ViewModel; }
|
||||
set { ViewModel = (ICreateRepoViewModel)value; }
|
||||
}
|
||||
|
||||
public ICreateRepoViewModel ViewModel
|
||||
{
|
||||
[return: AllowNull]
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace GitHub.VisualStudio.UI.Views.Controls
|
|||
/// Interaction logic for LoginControl.xaml
|
||||
/// </summary>
|
||||
[ExportView(ViewType=UIViewType.Login)]
|
||||
public partial class LoginControl : IViewFor<ILoginViewModel>
|
||||
public partial class LoginControl : IViewFor<ILoginViewModel>, IView
|
||||
{
|
||||
public LoginControl()
|
||||
{
|
||||
|
@ -45,6 +45,12 @@ namespace GitHub.VisualStudio.UI.Views.Controls
|
|||
set { ViewModel = (ILoginViewModel)value; }
|
||||
}
|
||||
|
||||
object IView.ViewModel
|
||||
{
|
||||
get { return ViewModel; }
|
||||
set { ViewModel = (ILoginViewModel)value; }
|
||||
}
|
||||
|
||||
public ILoginViewModel ViewModel
|
||||
{
|
||||
[return: AllowNull]
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace GitHub.VisualStudio.UI.Views.Controls
|
|||
/// Interaction logic for PasswordView.xaml
|
||||
/// </summary>
|
||||
[ExportView(ViewType=UIViewType.TwoFactor)]
|
||||
public partial class TwoFactorControl : IViewFor<ITwoFactorViewModel>
|
||||
public partial class TwoFactorControl : IViewFor<ITwoFactorViewModel>, IView
|
||||
{
|
||||
public TwoFactorControl()
|
||||
{
|
||||
|
@ -66,5 +66,11 @@ namespace GitHub.VisualStudio.UI.Views.Controls
|
|||
get { return ViewModel; }
|
||||
set { ViewModel = (ITwoFactorViewModel)value; }
|
||||
}
|
||||
|
||||
object IView.ViewModel
|
||||
{
|
||||
get { return ViewModel; }
|
||||
set { ViewModel = (ITwoFactorViewModel)value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче