コード例 #1
0
        private void RegisterDependencies()
        {
            DependencyInjector di = DependencyInjector.Instance;

            // Singleton services
            di.CreateSingleton <IViewResolver, ViewResolver>();
            di.CreateSingleton <INavigator, Navigator>(typeof(IViewResolver));
            di.CreateSingleton <ISensor, Kinect>();

            //View resolver setup
            IViewResolver vr = di.GetSingleton <IViewResolver>();

            vr.Register <MainViewModel, MainView>();
            vr.Register <DisposeViewModel, DisposeView>();
        }
コード例 #2
0
        public static void Register(DependencyInjector injector)
        {
            injector.CreateSingleton <ViewResolver, UwpViewResolver>();
            injector.CreateSingleton <Navigator, UwpNavigator>(typeof(ViewResolver));
            injector.CreateSingleton <Viewport, UwpViewport>();
            injector.CreateSingleton <MusicLoader, UwpMusicLoader>();
            injector.CreateSingleton <HttpService, UwpHttpService>();
            injector.CreateSingleton <Deserialiser, JsonDeserialiser>();
            injector.CreateSingleton <PhotoService, UnsplashService>(typeof(HttpService), typeof(Deserialiser));

            ViewResolver viewResolver = injector.GetSingleton <ViewResolver>();

            viewResolver.Register <MainViewModel, MainView>();
        }