Ejemplo n.º 1
0
        public void EachItem()
        {
            Client listClient = new ClientMock(MockResponse.PlaylistsList);

            foreach (Playlist item in PlaylistsList.EachItem(listClient))
            {
                Assert.That(listClient, Is.SameAs(item.record.RecordClient));
                Assert.AreEqual(item.record.RecordEndpoint, "feeds/playlists");
            }

            var per_page = "1";
            var query    = new Dictionary <string, string>()
            {
                { "per_page", per_page }
            };

            int countItem = 0;

            foreach (Playlist item in PlaylistsList.EachItem(query, listClient))
            {
                countItem++;
            }

            Assert.AreEqual(countItem.ToString(), per_page);
        }        // end
Ejemplo n.º 2
0
        private void AddPlaylist(object sender, RoutedEventArgs e)
        {
            // get list of currentPlaylists
            string playlists = makeRequest("api=pl");

            if (playlists != null && !string.IsNullOrWhiteSpace(playlists))
            {
                string       name;
                PlaylistName dl = new PlaylistName();
                dl.ShowDialog();
                if (dl.DialogResult != true)
                {
                    return;
                }
                name = dl.Name;
                if (name != null && !string.IsNullOrWhiteSpace(name))
                {
                    char[] sep = { '\n' };
                    if (!playlists.Split(sep).Contains(name))
                    {
                        string quaryString = "nores=create&item=" + name;
                        makeRequest(quaryString);
                        PlaylistsList.Add(new playlist(name));
                        NotifyPropertyChanged("PlaylistsList");
                    }
                    else
                    {
                        MessageBox.Show("There is already a playlist with this name!");
                    }
                }
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            PlaylistsList.SelectedIndex = 0;
            PlaylistsList.Focus();
            ((ListBoxItem)PlaylistsList.ItemContainerGenerator.ContainerFromIndex(0)).Focus();

            SplashWindow F = SplashWindow.Instance(this, Properties.Resources.AppIcon);

            F.CanClose();
            F.ShowDialog();

            var a = MediaInfo.GetVersion();
        }
Ejemplo n.º 4
0
        private void DelPlaylist(object sender, RoutedEventArgs e)
        {
            if (PlaylistComboBox.SelectedValue != null)
            {
                playlist pl = PlaylistComboBox.SelectedValue as playlist;
                makeRequest("api=pl&delete", true, "pl=" + pl.Name);

                PlaylistsList.Remove(pl);
                NotifyPropertyChanged("PlaylistsList");

                PlaylistComboBox.SelectedValue = null;
                m_selectetPlaylist             = null;
                NotifyPropertyChanged("SelectedPlaylist");
                NotifyPropertyChanged("PlaylistSelected");
            }
        }
        public async Task Init(PlaylistSearchRequest request = null)
        {
            PlaylistsList.Clear();
            try
            {
                var UserID = SignedInUserHelper.User.ID;

                var playlists = await _service.GetActivityPlaylists(UserID, request);

                foreach (var playlist in playlists)
                {
                    PlaylistsList.Add(playlist);
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 6
0
        public void NewPlaylistsList()
        {
            var list = new PlaylistsList();

            Assert.AreEqual(list.records.RecordEndpoint, "feeds/playlists");
            Assert.IsInstanceOf <List <Record> > (list.records.List);
            Assert.IsInstanceOf <List <Playlist> > (list.Page);

            var client = new ClientMock(MockResponse.PlaylistsList);

            list = new PlaylistsList(client);

            Assert.AreEqual(list.records.RecordEndpoint, "feeds/playlists");
            Assert.IsInstanceOf <List <Record> > (list.records.List);
            Assert.IsInstanceOf <List <Playlist> > (list.Page);

            Assert.IsInstanceOf <Client> (list.records.RecordClient);
        }
Ejemplo n.º 7
0
        public void Paginate()
        {
            var list = PlaylistsList.Paginate(new ClientMock(MockResponse.PlaylistsList));

            var listClient = list.records.RecordClient;

            Assert.AreEqual(list.records.RecordEndpoint, "feeds/playlists");

            foreach (var item in list.Page)
            {
                Assert.AreEqual(item.record.RecordEndpoint, "feeds/playlists");
            }

            var per_page = "1";
            var query    = new Dictionary <string, string>()
            {
                { "per_page", per_page }
            };

            var list2 = PlaylistsList.Paginate(query, new ClientMock(MockResponse.PlaylistsList));

            var countItem = 0;

            foreach (var item in list2.Page)
            {
                countItem++;
            }

            Assert.AreEqual(countItem.ToString(), per_page);

            list = PlaylistsList.Paginate(new ClientMock(MockResponse.RecordPaginate));

            Assert.IsTrue(list.Next());
            Assert.IsTrue(list.Prevous());
            Assert.IsTrue(list.First());
            Assert.IsTrue(list.Last());

            list = PlaylistsList.Paginate(new ClientMock(MockResponse.RecordPaginateEmpty));

            Assert.IsFalse(list.Next());
            Assert.IsFalse(list.Prevous());
            Assert.IsFalse(list.First());
            Assert.IsFalse(list.Last());
        }
        private async Task Search(object query)
        {
            string queryString = query as string;

            SearchQuery = queryString;
            if (!string.IsNullOrEmpty(queryString))
            {
                var request = new PlaylistSearchRequest()
                {
                    Name = queryString
                };

                var artistsList = await _playlistService.Get <List <Model.Playlist> >(request);

                PlaylistsList.Clear();
                foreach (var Item in artistsList)
                {
                    PlaylistsList.Add(Item);
                }
            }
        }
        public async Task Init(PlaylistSearchRequest request = null)
        {
            PlaylistsList.Clear();
            try
            {
                if (request == null)
                {
                    request = new PlaylistSearchRequest()
                    {
                        UserID = SignedInUserHelper.User.ID
                    };
                }

                var playlists = await _service.Get <List <Model.Playlist> >(request);

                foreach (var playlist in playlists)
                {
                    PlaylistsList.Add(playlist);
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 10
0
        public static void ReadingPlaylistsList(string id, string token)
        {
            try {
                Console.WriteLine("--EachItem()--");
                foreach (Playlist item in PlaylistsList.EachItem())
                {
                    Console.WriteLine("Id: " + item["id"] + " Title: " + item["title"]);
                }

                Console.WriteLine("--EachItem(query)--");

                Dictionary <string, string> query = new Dictionary <string, string>()
                {
                    { "sort", "created_at" },
                    { "order", "desc" },
                    { "per_page", "2" }
                };

                Client client = new Client()
                {
                    CfgClientId = id, CfgAuthToken = token
                };
                foreach (var item in PlaylistsList.EachItem(query, client))
                {
                    Console.WriteLine("Id: " + item["id"] + " Title: " + item["title"]);
                }

                Console.WriteLine("--Paginate--");

                var items1 = PlaylistsList.Paginate();
                foreach (var item in items1.Page)
                {
                    Console.WriteLine("Id: " + item["id"] + " Title: " + item["title"]);
                }

                Console.WriteLine("--Paginate(query)--");

                var items2 = PlaylistsList.Paginate(query, new Client());

                Console.WriteLine("--Paginate(query)--Initial-First--");
                foreach (var item in items2.Page)
                {
                    Console.WriteLine("Id: " + item["id"] + " Title: " + item["title"]);
                }

                while (items2.Next())
                {
                    Console.WriteLine("--Paginate(query)--Next--");

                    foreach (var item in items2.Page)
                    {
                        Console.WriteLine("Id: " + item["id"] + " Title: " + item["title"]);
                    }
                }

                Console.WriteLine("--Paginate(query)--Previous--");
                items2.Prevous();
                foreach (var item in items2.Page)
                {
                    Console.WriteLine("Id: " + item["id"] + " Title: " + item["title"]);
                }

                Console.WriteLine("--Paginate(query)--Last--");
                items2.Last();
                foreach (var item in items2.Page)
                {
                    Console.WriteLine("Id: " + item["id"] + " Title: " + item["title"]);
                }

                Console.WriteLine("--Paginate(query)--First--");
                items2.First();
                foreach (var item in items2.Page)
                {
                    Console.WriteLine("Id: " + item["id"] + " Title: " + item["title"]);
                }
            } catch (VzaarApiException ve) {
                Console.Write("!!!!!!!!! EXCEPTION !!!!!!!!!");
                Console.WriteLine(ve.Message);
            } catch (Exception e) {
                Console.Write("!!!!!!!!! EXCEPTION !!!!!!!!!");
                Console.WriteLine(e.Message);

                if (e is AggregateException)
                {
                    AggregateException ae = (AggregateException)e;

                    var flatten = ae.Flatten();

                    foreach (var fe in flatten.InnerExceptions)
                    {
                        if (fe is VzaarApiException)
                        {
                            Console.WriteLine(fe.Message);
                        }
                    }
                }
            }
        }