Ejemplo n.º 1
0
        protected override void OnStart()
        {
            var refitSettings = new RefitSettings();
            var jsonSettings  = new JsonSerializerSettings
            {
                MissingMemberHandling = MissingMemberHandling.Ignore
            };

            refitSettings.ContentSerializer = new NewtonsoftJsonContentSerializer(jsonSettings);

            var api                 = RestService.For <IMusicPlayerAPI>(HOST, refitSettings);
            var defaultCover        = ImageSource.FromResource("MusicPlayer.Resources.defaultCover.png", typeof(App));
            var defaultArtist       = ImageSource.FromResource("MusicPlayer.Resources.defaultArtist.png", typeof(App));
            var player              = new PlayingPage();
            var loadPlaylistCommand = ((PlayingViewModel)player.BindingContext).LoadPlaylistCommand;

            DependencyHelper.Builder.RegisterInstance(api);
            DependencyHelper.Builder.RegisterInstance(new List <Song>());
            DependencyHelper.Builder.RegisterInstance(defaultCover).Named <ImageSource>("defaultCover");
            DependencyHelper.Builder.RegisterInstance(defaultArtist).Named <ImageSource>("defaultArtist");
            DependencyHelper.Builder.RegisterInstance(loadPlaylistCommand).Named <Command>("loadPlaylist");
            DependencyHelper.Builder.RegisterInstance(new AppShell(player));


            DependencyHelper.BuildContainer();
            DependencyResolver.ResolveUsing(type => DependencyHelper.Container.IsRegistered(type) ? DependencyHelper.Container.Resolve(type) : null);
            MainPage = DependencyService.Resolve <AppShell>();
        }