Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
        protected override void Configure()
        {
            InteractionEffectManager.AllowedTypes.Add(typeof(RadDataBoundListBoxItem));

            container = new PhoneContainer(RootFrame);

            container.RegisterPhoneServices();

            // Loggers
            container.Singleton<ILog, DebugLogger>();

            // Database
            container.Handler<DbDataContext>(
                ioc =>
                new DbDataContext(DbDataContext.DbConnectionString)
                {
                    DeferredLoadingEnabled = false,
                    ObjectTrackingEnabled = true
                });

            using (var context = (DbDataContext)container.GetInstance(typeof(DbDataContext), null))
            {
                if (!context.DatabaseExists())
                {
                    context.CreateDatabase();
                    context.SubmitChanges();
                }
            }

            // Clients
            container
                .Singleton<ITwitterClient, TwitterClient>()
                .Singleton<IFacebookClient, FacebookClient>()
                .Singleton<ITrainshareClient, TrainshareClient>()
                .Singleton<ITimeTable, CacheTimeTable>();

            // ViewModels
            container
                .Singleton<MainPageViewModel>()
                .Singleton<MainViewModel>()
                .Singleton<AccountsViewModel>()
                .Singleton<AboutViewModel>()
                .PerRequest<SearchViewModel>()
                .PerRequest<SearchResultViewModel>()
                .PerRequest<CheckinViewModel>();

            AddCustomConventions();
        }