コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }