public static IServiceCollection AddPageSingleton <TView, TViewModel>(this IServiceCollection services) where TView : Page, IView where TViewModel : class, IViewModel { services.TryAddSingleton <INavigationLookup>(NavigationLookup); services.AddSingleton <TView>(); services.TryAddSingleton <TViewModel>(); NavigationLookup.Register <TView, TViewModel>(); return(services); }
public static IServiceCollection AddPage <TPage, TViewModel>(this IServiceCollection services) where TPage : BaseScreen <TViewModel>, IView where TViewModel : class, IViewModel { services.TryAddSingleton <INavigationLookup>(NavigationLookup); services.AddTransient <TPage>(); services.AddTransient <TViewModel>(); NavigationLookup.Register <TPage, TViewModel>(); return(services); }
public void SHOULD_return_type_registered_for_viewmodel() { //Arrange var sut = new NavigationLookup(); sut.Register <TestView, TestViewModel>(); //Act var result = sut.GetViewType <TestViewModel>(); //Assert Assert.AreEqual(typeof(TestView), result); }