コード例 #1
0
        public void EnsureGetMixesThrowsExceptionForNullGroup()
        {
            MixGroup     nullGroup = null;
            IMusicClient client    = new MusicClient("test", "gb", new MockApiRequestHandler(Resources.mixes));

            client.GetMixesAsync(nullGroup).Wait();
        }
コード例 #2
0
        /// <summary>
        /// Routes clicks on an MusicItem to the right place...
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="player">The player if the page has one.</param>
        /// <returns>
        /// A boolean indicating if we rooted the object successfully
        /// </returns>
        public async Task <bool> RouteItemClick(object item, MediaElement player)
        {
            Artist artist = item as Artist;

            if (artist != null)
            {
                App.RootFrame.Navigate(typeof(DetailPage), artist);
                return(true);
            }

            Product   product   = item as Product;
            UserEvent userEvent = item as UserEvent;

            if (userEvent != null && userEvent.Product != null)
            {
                product = userEvent.Product;
            }

            if (product != null)
            {
                if (product.Category == Category.Track)
                {
                    Debug.WriteLine("Track pressed");
                    await product.Show();
                }
                else if (product.Category == Category.Album)
                {
                    App.RootFrame.Navigate(typeof(DetailPage), product);
                }

                return(true);
            }

            Genre genre = item as Genre;

            if (genre != null)
            {
                App.RootFrame.Navigate(typeof(DetailPage), genre);
                return(true);
            }

            MixGroup group = item as MixGroup;

            if (group != null)
            {
                App.RootFrame.Navigate(typeof(ShowListPage), new ShowListParams(MethodCall.GetMixes, group.Id, group.Name));
                return(true);
            }

            Mix mix = item as Mix;

            if (mix != null)
            {
                await mix.Play();

                return(true);
            }

            return(false);
        }
コード例 #3
0
        public void TestParamConstructor()
        {
            MixGroup group = new MixGroup("1234", "Metal");

            Assert.AreEqual("1234", group.Id);
            Assert.AreEqual("Metal", group.Name);
        }
コード例 #4
0
ファイル: App.xaml.cs プロジェクト: tacongloc/wp-api-client
        /// <summary>
        /// Routes clicks on an MusicItem to the right place...
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="player">The player if the page has one.</param>
        /// <returns>
        /// A boolean indicating if we rooted the object successfully
        /// </returns>
        public bool RouteItemClick(object item, MediaElement player)
        {
            Artist artist = item as Artist;

            if (artist != null)
            {
                App.RootFrame.Navigate(typeof(DetailPage), artist);
                return(true);
            }

            Product product = item as Product;

            if (product != null)
            {
                if (product.Category == Category.Track)
                {
                    Debug.WriteLine("Track pressed");
                    ShowProductTask task = new ShowProductTask()
                    {
                        ProductId = product.Id
                    };
                    task.Show();
                }
                else if (product.Category == Category.Album)
                {
                    App.RootFrame.Navigate(typeof(DetailPage), product);
                }

                return(true);
            }

            Genre genre = item as Genre;

            if (genre != null)
            {
                App.RootFrame.Navigate(typeof(DetailPage), genre);
                return(true);
            }

            MixGroup group = item as MixGroup;

            if (group != null)
            {
                App.RootFrame.Navigate(typeof(ShowListPage), new ShowListParams(MethodCall.GetMixes, group.Id, group.Name));
                return(true);
            }

            Mix mix = item as Mix;

            if (mix != null)
            {
                mix.Play();
                return(true);
            }

            return(false);
        }
コード例 #5
0
        /// <summary>
        /// Gets the Mixes available in a group
        /// </summary>
        /// <param name="group">The mix group.</param>
        /// <param name="exclusiveTag">The exclusive tag.</param>
        /// <returns>
        /// A ListResponse containing Mixes or an Error
        /// </returns>
        public Task <ListResponse <Mix> > GetMixesAsync(MixGroup group, string exclusiveTag)
        {
            if (group == null)
            {
                throw new ArgumentNullException("group", "group cannot be null");
            }

            return(this.GetMixesAsync(group.Id, exclusiveTag));
        }
コード例 #6
0
        public void TestOverrides()
        {
            MixGroup group = new MixGroup()
            {
                Id = TestId, Name = TestName
            };

            Assert.IsNotNull(group.GetHashCode(), "Expected a hash code");
            Assert.IsFalse(group.Equals(TestId), "Expected inequality");
        }
コード例 #7
0
        public void TestProperties()
        {
            MixGroup group = new MixGroup()
            {
                Id = TestId, Name = TestName
            };

            Assert.AreEqual(TestId, group.Id, "Expected the property to persist");
            Assert.AreEqual(TestName, group.Name, "Expected the property to persist");
        }
コード例 #8
0
        public void TestJsonParsing()
        {
            MixGroup group = new MixGroup()
            {
                Id = "1234", Name = "Metal"
            };
            JObject  json     = JObject.Parse("{\"id\":\"1234\",\"name\":\"Metal\"}");
            MixGroup fromJson = MixGroup.FromJToken(json) as MixGroup;

            Assert.IsNotNull(fromJson, "Expected a MixGroup object");

            Assert.IsTrue(group.Equals(fromJson), "Expected the same MixGroup");
        }
コード例 #9
0
ファイル: EPSoundController.cs プロジェクト: eddaly/elvis
 public void SetMixGroupVolume( MixGroup grp, float vol )
 {
     m_MixGroupVolumes[(int)grp] = vol;
     foreach ( EPSoundEvent snd in m_EPSoundEventList )
     {
         snd.SetVolume ( snd.GetEventVolume() );
     }
 }
コード例 #10
0
        /// <summary>
        /// Routes clicks on an MusicItem to the right place...
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>A boolean indicating if we rooted the object successfully</returns>
        public bool RouteItemClick(object item)
        {
            Artist artist = item as Artist;

            if (artist != null)
            {
                string thumb = string.Empty;
                if (artist.Thumb200Uri != null)
                {
                    thumb = HttpUtility.UrlEncode(artist.Thumb200Uri.ToString());
                }

                this.RootFrame.Navigate(new Uri("/ArtistPage.xaml?" + App.IdParam + "=" + artist.Id + "&" + App.NameParam + "=" + HttpUtility.UrlEncode(artist.Name) + "&" + App.ThumbParam + "=" + thumb, UriKind.Relative));
                return(true);
            }

            Product product = item as Product;

            if (product != null)
            {
                if (product.Category == Category.Track)
                {
                    ShowProductTask task = new ShowProductTask()
                    {
                        ProductId = product.Id
                    };
                    task.Show();
                }
                else
                {
                    string thumb = string.Empty;
                    if (product.Thumb200Uri != null)
                    {
                        thumb = HttpUtility.UrlEncode(product.Thumb200Uri.ToString());
                    }

                    this.RootFrame.Navigate(new Uri("/AlbumPage.xaml?" + App.IdParam + "=" + product.Id + "&" + App.NameParam + "=" + HttpUtility.UrlEncode(product.Name) + "&" + App.ThumbParam + "=" + thumb, UriKind.Relative));
                }

                return(true);
            }

            Genre genre = item as Genre;

            if (genre != null)
            {
                this.RootFrame.Navigate(new Uri("/GenrePage.xaml?" + IdParam + "=" + genre.Id + "&" + App.NameParam + "=" + HttpUtility.UrlEncode(genre.Name), UriKind.Relative));
                return(true);
            }

            MixGroup group = item as MixGroup;

            if (group != null)
            {
                this.RootFrame.Navigate(new Uri("/ShowListPage.xaml?" + ShowListPage.MethodParam + "=" + MethodCall.GetMixes + "&" + IdParam + "=" + group.Id + "&" + NameParam + "=" + HttpUtility.UrlEncode(group.Name), UriKind.Relative));
                return(true);
            }

            Mix mix = item as Mix;

            if (mix != null)
            {
                PlayMixTask mixPlayer = new PlayMixTask()
                {
                    MixId = mix.Id
                };
                mixPlayer.Show();
                return(true);
            }

            return(false);
        }
コード例 #11
0
ファイル: App.xaml.cs プロジェクト: tOmoness/.net-sdk
        /// <summary>
        /// Routes clicks on an MusicItem to the right place...
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>A boolean indicating if we rooted the object successfully</returns>
        public async Task <bool> RouteItemClick(object item)
        {
            Artist artist = item as Artist;

            if (artist != null)
            {
                string thumb = string.Empty;
                if (artist.Thumb200Uri != null)
                {
                    thumb = HttpUtility.UrlEncode(artist.Thumb200Uri.ToString());
                }

                string musicbrainzId = string.Empty;
                if (!string.IsNullOrEmpty(artist.MusicBrainzId))
                {
                    musicbrainzId = "&" + App.MbIdParam + "=" + artist.MusicBrainzId;
                }

                this.RootFrame.Navigate(new Uri(
                                            "/ArtistPage.xaml?" + App.IdParam + "=" + artist.Id
                                            + "&" + App.NameParam + "=" + HttpUtility.UrlEncode(artist.Name)
                                            + "&" + App.ThumbParam + "=" + thumb
                                            + musicbrainzId,
                                            UriKind.Relative));
                return(true);
            }

            Product product = item as Product;

            if (product != null)
            {
                if (product.Category == Category.Track)
                {
                    ShowProductTask task = new ShowProductTask()
                    {
                        ClientId = ApiKeys.ClientId, ProductId = product.Id
                    };
                    await task.Show();
                }
                else
                {
                    string thumb = string.Empty;
                    if (product.Thumb200Uri != null)
                    {
                        thumb = HttpUtility.UrlEncode(product.Thumb200Uri.ToString());
                    }

                    this.RootFrame.Navigate(new Uri("/AlbumPage.xaml?" + App.IdParam + "=" + product.Id + "&" + App.NameParam + "=" + HttpUtility.UrlEncode(product.Name) + "&" + App.ThumbParam + "=" + thumb, UriKind.Relative));
                }

                return(true);
            }

            Genre genre = item as Genre;

            if (genre != null)
            {
                this.RootFrame.Navigate(new Uri("/GenrePage.xaml?" + IdParam + "=" + genre.Id + "&" + App.NameParam + "=" + HttpUtility.UrlEncode(genre.Name), UriKind.Relative));
                return(true);
            }

            MixGroup group = item as MixGroup;

            if (group != null)
            {
                this.RootFrame.Navigate(new Uri("/ShowListPage.xaml?" + ShowListPage.MethodParam + "=" + MethodCall.GetMixes + "&" + IdParam + "=" + group.Id + "&" + NameParam + "=" + HttpUtility.UrlEncode(group.Name), UriKind.Relative));
                return(true);
            }

            Mix mix = item as Mix;

            if (mix != null)
            {
                await mix.Play();

                return(true);
            }

            return(false);
        }
コード例 #12
0
 /// <summary>
 /// Gets the Mixes available in a group
 /// </summary>
 /// <param name="group">The mix group.</param>
 /// <returns>
 /// A ListResponse containing Mixes or an Error
 /// </returns>
 public Task <ListResponse <Mix> > GetMixesAsync(MixGroup group)
 {
     return(this.GetMixesAsync(group, null));
 }
コード例 #13
0
        public void HashCodeCanBeRetrievedWhenIdIsNull()
        {
            MixGroup mixGroup = new MixGroup();

            Assert.IsNotNull(mixGroup.GetHashCode(), "Expected a hash code");
        }