Exemple #1
0
        protected override void Configure()
        {
            container = new PhoneContainer(RootFrame);
            container.Singleton <IEventAggregator, EventAggregator>();
            container.PerRequest <HelpPageViewModel>();
            container.PerRequest <PresetsPageViewModel>();
            container.PerRequest <PresetViewModel>();
            container.PerRequest <SavedFilesViewModel>();
            container.PerRequest <MainMenuPageViewModel>();

            container.PerRequest <MainPageViewModel>();
            container.Handler <ISettings>(simpleContainer => new Settings(IsolatedStorageSettings.ApplicationSettings));
            container.PerRequest <SettingsPageViewModel>();
            container.PerRequest <HearingTestViewModel>();
            container.PerRequest <HostPageViewModel>();
            container.PerRequest <HearingTestView>();
            container.PerRequest <RecentPageViewModel>();
            container.PerRequest <IAudiogramPlot, AudiogramPlot>();
            container.PerRequest <BrowserPageViewModel>();
            container.PerRequest <DataViewModel>();
            container.PerRequest <PlotViewModel>();
            container.Handler <IStorageFolder>(simpleContainer => ApplicationData.Current.LocalFolder);
            container.PerRequest <IAsyncXmlFileManager, AsyncXmlFileManager>();
            container.Handler <ISkyDriveUpload>(
                simpleContainer =>
                new SkyDriveUpload((IStorageFolder)simpleContainer.GetInstance(typeof(IStorageFolder), null),
                                   (ISettings)simpleContainer.GetInstance(typeof(ISettings), null)));
            container.PerRequest <ResultsPageViewModel>();
            container.RegisterPerRequest(typeof(AddItemViewModel), "AddItemViewModel", typeof(AddItemViewModel));
            container.RegisterPerRequest(typeof(SaveResultViewModel), "SaveResultViewModel", typeof(SaveResultViewModel));
            container.PerRequest <IDialogBuilder <AddItemView, AddItemViewModel>, DialogBuilder <AddItemView, AddItemViewModel> >();
            container.PerRequest <IDialogBuilder <SaveResultView, SaveResultViewModel>, DialogBuilder <SaveResultView, SaveResultViewModel> >();
            container.Handler <IOscillator>(simpleContainer => new SineOscillator(-95, 100));
            container.Handler <IPitchGenerator>(
                simpleContainer =>
                new PitchGenerator((IOscillator)simpleContainer.GetInstance(typeof(IOscillator), null)));
            container.RegisterPhoneServices();
            AddDefaultSettings();
            AddConventions();
        }
        private void RegisterServices()
        {
            _phoneContainer.RegisterInstance(typeof(IAnalytics), null, _analytics);

            _phoneContainer.RegisterHandler(typeof(ILocalizationManager), null, c => Application.Current.Resources["Localization"]);
            _phoneContainer.RegisterHandler(typeof(IBusyIndicatorManager), null, c => BusyIndicatorManager.Create((PhoneApplicationPage)RootFrame.Content));
            _phoneContainer.Singleton <SettingsController>();
            _phoneContainer.PerRequest <INotificationsService, NotificationsService>();
            _phoneContainer.PerRequest <IErrorHandler, ErrorHandler>();

            _phoneContainer.PerRequest <ITileManager, TileManager>();
            _phoneContainer.PerRequest <IBookRepository, BookRepository>();
            _phoneContainer.PerRequest <ICatalogRepository, CatalogRepository>();
            _phoneContainer.PerRequest <IWebDataGateway, WebDataGateway>();
            _phoneContainer.PerRequest <IWebClient, WebClient.WebClient>();
            _phoneContainer.PerRequest <ICatalogReaderFactory, CatalogReaderFactory>();
            _phoneContainer.PerRequest <ICatalogAuthorizationFactory, CatalogAuthorizationFactory>();
            _phoneContainer.PerRequest <IAcquisitionServiceFactory, AcquisitionServiceFactory>();

            _phoneContainer.Singleton <BookmarksController>();
            _phoneContainer.PerRequest <IBookmarkRepository, BookmarkRepository>();

            _phoneContainer.Singleton <SearchInBookController>();

            _phoneContainer.PerRequest <BookSearch>();

            _phoneContainer.Singleton <ISdCardStorage, SdCardStorage>();
            _phoneContainer.PerRequest <DataBaseInitializer>();

            _phoneContainer.PerRequest <IStorageStateSaver, StorageStateSaver>();

            _phoneContainer.PerRequest <ILiveLogin, LiveLogin>();
            _phoneContainer.PerRequest <ISkyDriveService, SkyDriveService>();

            _phoneContainer.Handler <AppSettings>(container => AppSettings.Default);

            _phoneContainer.PerRequest <SharingDataModel>();

            _phoneContainer.PerRequest <IBusyOverlayManager, BusyOverlayManager>();

            _phoneContainer.PerRequest <BookTool>();

            _phoneContainer.Singleton <CatalogController>();

            _phoneContainer.PerRequest <IFileLoadingFactory, FileLoadingFactory>();
            _phoneContainer.Singleton <DownloadController>();
            _phoneContainer.Singleton <IBookDownloader, BookDownloader>();
            _phoneContainer.Singleton <IDownloadsContainer, DownloadsContainer>();
            _phoneContainer.PerRequest <IBookDownloadsRepository, BookDownloadsRepository>();
        }