private bool IsValidTrack(Track t)
 {
     return !string.IsNullOrEmpty(t.Position);
 }
Ejemplo n.º 2
0
        public static Track ReadTrack(XElement el)
        {
            el.AssertName("track");
            el.AssertNoAttributes();

            Track result = new Track();

            foreach (XElement e in el.Elements())
            {
                if (e.Name == "position")
                {
                    e.AssertOnlyText();
                    result.Position = e.Value;
                }
                else if (e.Name == "title")
                {
                    e.AssertOnlyText();
                    result.Title = e.Value;
                }
                else if (e.Name == "duration")
                {
                    e.AssertOnlyText();
                    result.Duration = e.Value;
                }
                else if (e.Name == "artists")
                {
                    result.Artists = e.Elements().Select(a => ReadReleaseArtist(a)).ToArray();
                }
                else if (e.Name == "extraartists")
                {
                    result.ExtraArtists = e.Elements().Select(a => ReadExtraArtist(a)).ToArray();
                }
                else
                {
                    throw new Exception("Unknown track element: " + e.Name);
                }
            }

            return result;
        }
Ejemplo n.º 3
0
        private Track ReadTrack()
        {
            this.XmlReader.AssertElementStart("track");

            Track track = new Track();

            while (true)
            {
                this.XmlReader.AssertRead();

                if (this.XmlReader.IsElementEnd("track"))
                {
                    break;
                }

                if (this.XmlReader.IsElementStart("position"))
                {
                    if (!this.XmlReader.IsEmptyElement)
                    {
                        this.XmlReader.AssertRead();
                        track.Position = this.XmlReader.ReadContentAsString();
                    }
                }
                else if (this.XmlReader.IsElementStart("title"))
                {
                    if (!this.XmlReader.IsEmptyElement)
                    {
                        this.XmlReader.AssertRead();
                        track.Title = this.XmlReader.ReadContentAsString();
                    }
                }
                else if (this.XmlReader.IsElementStart("duration"))
                {
                    if (!this.XmlReader.IsEmptyElement)
                    {
                        this.XmlReader.AssertRead();
                        track.Duration = this.XmlReader.ReadContentAsString();
                    }
                }
                else if (this.XmlReader.IsStartElement("extraartists"))
                {
                    track.ExtraArtists = this.ReadExtraArtists();
                }
                else if (this.XmlReader.IsElementStart("artists"))
                {
                    track.Artists = this.ReadReleaseArtists();
                }
                else
                {
                    this.ThrowInvalidFormatException();
                }
            }

            return track;
        }
Ejemplo n.º 4
0
 public TrackAggregate(Track track)
 {
     this.track = track;
 }
Ejemplo n.º 5
0
        private Track ReadReleaseTrack(JObject source)
        {
            Track track = new Track();
            foreach (var item in source)
            {
                var v = item.Value;

                switch (item.Key)
                {
                    case "duration":
                        track.Duration = v.Value<string>();
                        break;
                    case "position":
                        track.Position = v.Value<string>();
                        break;
                    case "title":
                        track.Title = v.Value<string>();
                        break;
                    case "artists":
                        track.Artists = this.ReadReleaseArtists(v.Value<JArray>());
                        break;
                    case "extraartists":
                        track.ExtraArtists = this.ReadExtraArtists(v.Value<JArray>());
                        break;
                    default:
                        this.ThrowIfStrict("Unknown key: " + item.Key);
                        break;
                }
            }
            return track;
        }