Пример #1
0
        private IContainer CreateContainer()
        {
            var container = new MetroContainer();

            container.RegisterInstance(container);
            container.RegisterInstance <IContainer>(container);
            container.Register <INavigationService, NavigationService>
                (lifecycle: new SingletonLifecycle());
            return(container);
        }
        public static IContainer BuildContainer()
        {
            container.RegisterInstance(container);
            container.RegisterInstance <IContainer>(container);

            container.Register <IHub, MessageHub>();
            container.Register <IDialogService, DialogService>();
            container.Register <INavigationService, NavigationService>(null, registration: new Singleton());

            container.Register <UndoRedoService>(null, registration: new Singleton());
            container.Register <SearchService>(null, registration: new Singleton());

            container.Register <ShellViewModel>(null, registration: new Singleton());
            container.Register <StartPageViewModel>(null, registration: new Singleton());
            container.Register <WordsWithTheSameLengthViewModel>(null, registration: new Singleton());

            RegisterHandlers(container);

            return(container);
        }
Пример #3
0
        public static IContainer BuildContainer()
        {
            var container = new MetroContainer();
            container.RegisterInstance(container);
            container.RegisterInstance<IContainer>(container);

            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                container.Register<IBackgroundDownloader, NullBackgroundDownloader>();
                container.RegisterInstance<ApplicationSettings>(new NullApplicationSettings());
                container.Register<IImageSearchService, NullImageSearchService>();
            }
            else
            {
                container.Register<IBackgroundDownloader, BackgroundDownloaderAdapter>();
                container.RegisterInstance<ApplicationSettings>(new ApplicationSettings(container.Resolve<IBackgroundDownloader>()));
                container.RegisterInstance<BingApi>("<Account Key>");
                container.Register<IImageSearchService, BingImageSearchService>();
            }

            container.RegisterInstance<AppName>("PhotoZoom Navigation");
            container.RegisterInstance<IDataTransferManager>(new DataTransferManagerAdapter());
            container.RegisterInstance<ILockScreen>(new LockScreenAdapter());
            container.Register<IAccelerometer, AccelerometerAdapter>(lifecycle: new SingletonLifecycle());
            container.Register<INavigationService, NavigationService>(lifecycle: new SingletonLifecycle());
            container.Register<IFileOpenPickerUiManager, FileOpenPickerUiManager>(lifecycle: new SingletonLifecycle());
            container.Register<IHub, MessageHub>(lifecycle: new SingletonLifecycle());
            container.Register<IShareDataRequestedPump, ShareDataRequestedPump>(lifecycle: new SingletonLifecycle());
            container.Register<IDialogService, DialogService>();
            container.Register<ITileUpdateManager, TileUpdateManagerAdapter>();
            container.Register<IToastNotificationManager, ToastNotificationManagerAdapter>();
            container.Register<IPickerFactory, PickerFactory>();

            RegisterHandlers(container);

            container.Register<ShellViewModel>(lifecycle: new SingletonLifecycle());
            // I would prefer not to immediately resolve a singleton, but the MetroContainer doesn't support resolving from Method or provider alternatives.
            container.RegisterInstance<IStatusService>(container.Resolve<ShellViewModel>());

            return container;
        }
Пример #4
0
        public static IContainer BuildContainer()
        {
            var container = new MetroContainer();

            container.RegisterInstance(container);
            container.RegisterInstance <IContainer>(container);

            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                container.Register <IBackgroundDownloader, NullBackgroundDownloader>();
                container.RegisterInstance <ApplicationSettings>(new NullApplicationSettings());
                container.Register <IImageSearchService, NullImageSearchService>();
            }
            else
            {
                container.Register <IBackgroundDownloader, BackgroundDownloaderAdapter>();
                container.RegisterInstance <ApplicationSettings>(new ApplicationSettings(container.Resolve <IBackgroundDownloader>()));
                container.RegisterInstance <BingApi>("<Account Key>");
                container.Register <IImageSearchService, BingImageSearchService>();
            }

            container.RegisterInstance <AppName>("PhotoZoom Navigation");
            container.RegisterInstance <IDataTransferManager>(new DataTransferManagerAdapter());
            container.RegisterInstance <ILockScreen>(new LockScreenAdapter());
            container.Register <IAccelerometer, AccelerometerAdapter>(lifecycle: new SingletonLifecycle());
            container.Register <INavigationService, NavigationService>(lifecycle: new SingletonLifecycle());
            container.Register <IFileOpenPickerUiManager, FileOpenPickerUiManager>(lifecycle: new SingletonLifecycle());
            container.Register <IHub, MessageHub>(lifecycle: new SingletonLifecycle());
            container.Register <IShareDataRequestedPump, ShareDataRequestedPump>(lifecycle: new SingletonLifecycle());
            container.Register <IDialogService, DialogService>();
            container.Register <ITileUpdateManager, TileUpdateManagerAdapter>();
            container.Register <IToastNotificationManager, ToastNotificationManagerAdapter>();
            container.Register <IPickerFactory, PickerFactory>();

            RegisterHandlers(container);

            container.Register <ShellViewModel>(lifecycle: new SingletonLifecycle());
            // I would prefer not to immediately resolve a singleton, but the MetroContainer doesn't support resolving from Method or provider alternatives.
            container.RegisterInstance <IStatusService>(container.Resolve <ShellViewModel>());

            return(container);
        }