Represents a recording.
コード例 #1
0
        private Recording ParseRecording(XElement el)
        {
            int duration = 0;
            string id = String.Empty;
            string title = String.Empty;

            XElement element = el.Element("duration");

            if (element != null)
            {
                duration = int.Parse(element.Value);
            }

            element = el.Element("id");

            if (element != null)
            {
                id = element.Value;
            }

            element = el.Element("title");

            if (element != null)
            {
                title = element.Value;
            }

            var recording = new Recording(duration, id, title);

            element = el.Element("artists");

            if (element != null)
            {
                var list = element.Elements("artist");

                foreach (var item in list)
                {
                    recording.Artists.Add(ParseArtist(item));
                }
            }

            element = el.Element("releasegroups");

            if (element != null)
            {
                var list = element.Elements("releasegroup");

                foreach (var item in list)
                {
                    recording.ReleaseGroups.Add(ParseReleaseGroup(item));
                }
            }

            // TODO: parse more meta
            return recording;
        }
コード例 #2
0
        private Recording ParseRecording(XElement node)
        {
            int duration;
            string id, title;

            TryParseChild(node, "id", out id);
            TryParseChild(node, "title", out title);
            TryParseChild(node, "duration", 0, out duration);
            
            var recording = new Recording(duration, id, title);

            var e = node.Element("artists");

            if (e != null)
            {
                var list = e.Elements("artist");

                foreach (var item in list)
                {
                    recording.Artists.Add(ParseArtist(item));
                }
            }

            e = node.Element("releasegroups");

            if (e != null)
            {
                var list = e.Elements("releasegroup");

                foreach (var item in list)
                {
                    recording.ReleaseGroups.Add(ParseReleaseGroup(item));
                }
            }

            e = node.Element("releases");

            if (e != null)
            {
                var list = e.Elements("release");

                foreach (var item in list)
                {
                    recording.Releases.Add(ParseRelease(item));
                }
            }

            // TODO: parse more meta
            return recording;
        }