예제 #1
0
        public Locator()
        {
            Container = new Container();
            Container.Register<IBitmapFactory, PclBitmapFactory>(Reuse.Singleton);
            Container.Register<IAppSettingsHelper, AppSettingsHelper>(Reuse.Singleton);
            Container.Register<IDispatcherHelper, DispatcherHelper>(Reuse.Singleton);
            Container.Register<INotificationManager, NotificationManager>(Reuse.Singleton);
            Container.Register<ICredentialHelper, CredentialHelper>(Reuse.Singleton);

            var factory = new AudioticaFactory(DispatcherHelper, AppSettingsHelper, BitmapFactory);

            Container.Register<IScrobblerService, ScrobblerService>(Reuse.Singleton);
            Container.Register<SpotifyWebApi>(Reuse.Singleton);
            Container.Register<ISpotifyService, SpotifyService>(Reuse.Singleton);

            Container.RegisterDelegate(r => factory.CreateCollectionSqlService(10), Reuse.Singleton);
            Container.RegisterDelegate(r => factory.CreatePlayerSqlService(4), Reuse.Singleton, named: "BackgroundSql");
            Container.RegisterDelegate(r => factory.CreateCollectionService(SqlService, BgSqlService), Reuse.Singleton);

            Container.Register<Mp3MatchEngine>(Reuse.Singleton);
        }
예제 #2
0
        public Locator()
        {
            Container = new Container();
            Container.Register <IBitmapFactory, PclBitmapFactory>(Reuse.Singleton);
            Container.Register <IAppSettingsHelper, AppSettingsHelper>(Reuse.Singleton);
            Container.Register <IDispatcherHelper, DispatcherHelper>(Reuse.Singleton);
            Container.Register <INotificationManager, NotificationManager>(Reuse.Singleton);
            Container.Register <ICredentialHelper, CredentialHelper>(Reuse.Singleton);

            var factory = new AudioticaFactory(DispatcherHelper, AppSettingsHelper, BitmapFactory);

            Container.Register <IScrobblerService, ScrobblerService>(Reuse.Singleton);
            Container.Register <SpotifyWebApi>(Reuse.Singleton);
            Container.Register <ISpotifyService, SpotifyService>(Reuse.Singleton);

            Container.RegisterDelegate(r => factory.CreateCollectionSqlService(10), Reuse.Singleton);
            Container.RegisterDelegate(r => factory.CreatePlayerSqlService(4), Reuse.Singleton, named: "BackgroundSql");
            Container.RegisterDelegate(r => factory.CreateCollectionService(SqlService, BgSqlService), Reuse.Singleton);

            Container.Register <Mp3MatchEngine>(Reuse.Singleton);
        }
예제 #3
0
        /// <summary>
        ///     Initializes a new instance of the ViewModelLocator class.
        /// </summary>
        public ViewModelLocator()
        {
            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

            SimpleIoc.Default.Register<INotificationManager, NotificationManager>();
            SimpleIoc.Default.Register<ICredentialHelper, PclCredentialHelper>();
            SimpleIoc.Default.Register<IAppSettingsHelper, AppSettingsHelper>();
            SimpleIoc.Default.Register<IBitmapFactory, PclBitmapFactory>();

            SimpleIoc.Default.Register<SpotifyWebApi>();
            SimpleIoc.Default.Register<ISpotifyService, SpotifyService>();

            SimpleIoc.Default.Register<IDeezerService, DeezerService>();

            if (ViewModelBase.IsInDesignModeStatic)
            {
                SimpleIoc.Default.Register<IAudioticaService, DesignAudioticaService>();
                SimpleIoc.Default.Register<IScrobblerService, DesignScrobblerService>();
                SimpleIoc.Default.Register<ICollectionService, DesignCollectionService>();
                SimpleIoc.Default.Register<ISqlService, DesignSqlService>();
            }
            else
            {
                SimpleIoc.Default.Register<IDispatcherHelper>(() => new PclDispatcherHelper(DispatcherHelper.UIDispatcher));

                SimpleIoc.Default.Register<IScrobblerService, ScrobblerService>();

                var factory = new AudioticaFactory(PclDispatcherHelper, AppSettingsHelper, BitmapFactory);

                SimpleIoc.Default.Register(() => factory.CreateCollectionSqlService(11, async (connection, d) =>
                {
                    if (!(d > 0) || !(d < 8)) return;

                    if (App.Locator.CollectionService.IsLibraryLoaded)
                        await CollectionHelper.MigrateAsync();
                    else
                        App.Locator.CollectionService.LibraryLoaded += (sender, args) =>
                            CollectionHelper.MigrateAsync();
                }));
                SimpleIoc.Default.Register(() => factory.CreatePlayerSqlService(6), "BackgroundSql");
                SimpleIoc.Default.Register(() => factory.CreateCollectionService(SqlService, BgSqlService));
                SimpleIoc.Default.Register<IAudioticaService, AudioticaService>();
            }

            SimpleIoc.Default.Register<ISongDownloadService>(() => new SongDownloadService(CollectionService, SqlService, DispatcherHelper.UIDispatcher));
            SimpleIoc.Default.Register<Mp3MatchEngine>();
            SimpleIoc.Default.Register<AppVersionHelper>();
            SimpleIoc.Default.Register<CollectionCommandHelper>();
            SimpleIoc.Default.Register<AudioPlayerHelper>();
            SimpleIoc.Default.Register<CollectionViewModel>(true);
            SimpleIoc.Default.Register<MainViewModel>();
            SimpleIoc.Default.Register<PlayerViewModel>();
            SimpleIoc.Default.Register<AudioticaCloudViewModel>();
            SimpleIoc.Default.Register<AlbumViewModel>();
            SimpleIoc.Default.Register<CollectionAlbumViewModel>();
            SimpleIoc.Default.Register<CollectionArtistViewModel>();
            SimpleIoc.Default.Register<CollectionPlaylistViewModel>();
            SimpleIoc.Default.Register<ArtistViewModel>();
            SimpleIoc.Default.Register<SearchViewModel>();
            SimpleIoc.Default.Register<SpotifyAlbumViewModel>();
            SimpleIoc.Default.Register<SpotifyArtistViewModel>();
            SimpleIoc.Default.Register<SettingsViewModel>();
            SimpleIoc.Default.Register<CollectionStatisticsViewModel>();
            SimpleIoc.Default.Register<ManualMatchViewModel>();
        }
예제 #4
0
        /// <summary>
        ///     Initializes a new instance of the ViewModelLocator class.
        /// </summary>
        public ViewModelLocator()
        {
            ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);

            SimpleIoc.Default.Register <AudioticaPluginHelper>();
            SimpleIoc.Default.Register <INotificationManager, NotificationManager>();
            SimpleIoc.Default.Register <ICredentialHelper, PclCredentialHelper>();
            SimpleIoc.Default.Register <IAppSettingsHelper, AppSettingsHelper>();
            SimpleIoc.Default.Register <IBitmapFactory, PclBitmapFactory>();

            SimpleIoc.Default.Register <SpotifyWebApi>();
            SimpleIoc.Default.Register <ISpotifyService, SpotifyService>();

            SimpleIoc.Default.Register <IDeezerService, DeezerService>();

            if (ViewModelBase.IsInDesignModeStatic)
            {
                SimpleIoc.Default.Register <IAudioticaService, DesignAudioticaService>();
                SimpleIoc.Default.Register <IScrobblerService, DesignScrobblerService>();
                SimpleIoc.Default.Register <ICollectionService, DesignCollectionService>();
                SimpleIoc.Default.Register <ISqlService, DesignSqlService>();
            }
            else
            {
                SimpleIoc.Default.Register <IDispatcherHelper>(() => new PclDispatcherHelper(DispatcherHelper.UIDispatcher));

                SimpleIoc.Default.Register <IScrobblerService, ScrobblerService>();

                var factory = new AudioticaFactory(PclDispatcherHelper, AppSettingsHelper, BitmapFactory);

                SimpleIoc.Default.Register(() => factory.CreateCollectionSqlService(11, async(connection, d) =>
                {
                    if (!(d > 0) || !(d < 8))
                    {
                        return;
                    }

                    if (App.Locator.CollectionService.IsLibraryLoaded)
                    {
                        await CollectionHelper.MigrateAsync();
                    }
                    else
                    {
                        App.Locator.CollectionService.LibraryLoaded += (sender, args) =>
                                                                       CollectionHelper.MigrateAsync();
                    }
                }));
                SimpleIoc.Default.Register(() => factory.CreatePlayerSqlService(6), "BackgroundSql");
                SimpleIoc.Default.Register(() => factory.CreateCollectionService(SqlService, BgSqlService));
                SimpleIoc.Default.Register <IAudioticaService, AudioticaService>();
            }

            SimpleIoc.Default.Register <ISongDownloadService>(() => new SongDownloadService(CollectionService, SqlService, DispatcherHelper.UIDispatcher));
            SimpleIoc.Default.Register <Mp3MatchEngine>();
            SimpleIoc.Default.Register <AppVersionHelper>();
            SimpleIoc.Default.Register <CollectionCommandHelper>();
            SimpleIoc.Default.Register <AudioPlayerHelper>();
            SimpleIoc.Default.Register <CollectionViewModel>(true);
            SimpleIoc.Default.Register <MainViewModel>();
            SimpleIoc.Default.Register <PlayerViewModel>();
            SimpleIoc.Default.Register <AudioticaCloudViewModel>();
            SimpleIoc.Default.Register <AlbumViewModel>();
            SimpleIoc.Default.Register <CollectionAlbumViewModel>();
            SimpleIoc.Default.Register <CollectionArtistViewModel>();
            SimpleIoc.Default.Register <CollectionPlaylistViewModel>();
            SimpleIoc.Default.Register <ArtistViewModel>();
            SimpleIoc.Default.Register <SearchViewModel>();
            SimpleIoc.Default.Register <SpotifyAlbumViewModel>();
            SimpleIoc.Default.Register <SpotifyArtistViewModel>();
            SimpleIoc.Default.Register <SettingsViewModel>();
            SimpleIoc.Default.Register <CollectionStatisticsViewModel>();
            SimpleIoc.Default.Register <ManualMatchViewModel>();
        }