コード例 #1
0
        protected override void Configure()
        {
            _container = new WinRTContainer();
            _container.RegisterWinRTServices();

            _container.Singleton <IWeatherService, WeatherService>();
            _container.Singleton <IWeatherProvider, WeatherProvider>();
            _container.Singleton <AppNavigationService>();
            _container.Singleton <IInteractionService, InteractionService>();
            _container.Handler <IAppNavigationService>(cnt => cnt.GetInstance <AppNavigationService>());

            _container.PerRequest <ShellViewModel>();
            _container.PerRequest <HomeViewModel>();
            _container.PerRequest <SecondPageViewModel>();
            _container.PerRequest <ThirdPageViewModel>();


            var config = new TypeMappingConfiguration
            {
                DefaultSubNamespaceForViews      = "Weather.UWP.Views",
                DefaultSubNamespaceForViewModels = "Weather.Core.ViewModels"
            };

            ViewLocator.ConfigureTypeMappings(config);
            ViewModelLocator.ConfigureTypeMappings(config);
        }
コード例 #2
0
        protected override void Configure()
        {
            _container = new WinRTContainer();
            _container.RegisterWinRTServices();

            _container.Singleton <INotesService, NotesService>();
            _container.Singleton <INotesProvider, NotesProvider>();
            _container.Singleton <ILocalStorage, LocalStorage>();
            _container.Singleton <AppNavigationService>();
            _container.Singleton <IInteractionService, InteractionService>();
            _container.Handler <IAppNavigationService>(cnt => cnt.GetInstance <AppNavigationService>());


            _container.PerRequest <ShellViewModel>();
            _container.PerRequest <ShowNotesViewModel>();
            _container.PerRequest <CreateNoteViewModel>();
            _container.PerRequest <FavoriteNotesViewModel>();

            var config = new TypeMappingConfiguration
            {
                DefaultSubNamespaceForViews      = "Notes.Views",
                DefaultSubNamespaceForViewModels = "Notes.Core.ViewModels"
            };

            ViewLocator.ConfigureTypeMappings(config);
            ViewModelLocator.ConfigureTypeMappings(config);
        }
コード例 #3
0
ファイル: App.xaml.cs プロジェクト: hypnot1c/iVM
        protected override void Configure()
        {
            _container = new WinRTContainer();

            _container.RegisterWinRTServices();

            _container.Handler <VehicleContext>(sc =>
            {
                var optionsBuilder = new DbContextOptionsBuilder <VehicleContext>();
                optionsBuilder.UseInMemoryDatabase("vehicle");

                return(new VehicleContext(optionsBuilder.Options));
            });

            _container.Handler <MasterContext>(sc =>
            {
                var optionsBuilder = new DbContextOptionsBuilder <MasterContext>();
                optionsBuilder.UseInMemoryDatabase("master");

                return(new MasterContext(optionsBuilder.Options));
            });

            // Make sure to register your containers here
            _container
            //.Instance<IConfigurationService>(new ConfigurationService())
            .Singleton <UserSessionService>()
            .PerRequest <WelcomeViewModel>()
            .PerRequest <VehicleTypeSelectViewModel>()
            .PerRequest <CarAddViewModel>()
            .PerRequest <ShellViewModel>()
            .PerRequest <PivotViewModel>()
            .PerRequest <EventListViewModel>()
            .PerRequest <EventTypeSelectViewModel>()
            .PerRequest <FillUpAddViewModel>()
            ;


            this._eventAggregator = _container.GetInstance <IEventAggregator>();

            var vehicleContext = _container.GetInstance <VehicleContext>();

            vehicleContext.FillDummyData();
            //var mainContext = _container.GetInstance<MasterContext>();
            //mainContext.FillDummyData();
        }