Пример #1
0
        public static LabelRelease ReadLabelRelease(XElement labelRelease)
        {
            labelRelease.AssertName("release");

            LabelRelease result = new LabelRelease();

            foreach (XAttribute attr in labelRelease.Attributes())
            {
                if (attr.Name == "id")
                {
                    result.Id = int.Parse(attr.Value);
                }
                else if (attr.Name == "status")
                {
                    result.Status = ParseReleaseStatus(attr.Value);
                }
                else
                {
                    throw new Exception("Unknown label release attribute: " + attr.Name);
                }
            }

            foreach (XElement e in labelRelease.Elements())
            {
                if (e.Name == "title")
                {
                    e.AssertOnlyText();
                    result.Title = e.Value;
                }
                else if (e.Name == "catno")
                {
                    e.AssertOnlyText();
                    result.CatalogNumber = e.Value;
                }
                else if (e.Name == "artist")
                {
                    e.AssertOnlyText();
                    result.Artist = e.Value;
                }
                else if (e.Name == "format")
                {
                    e.AssertOnlyText();
                    result.Format = e.Value;
                }
                else
                {
                    throw new Exception("Unknown label release element: " + e.Name);
                }
            }

            return(result);
        }
Пример #2
0
        public static LabelRelease ReadLabelRelease(XElement labelRelease)
        {
            labelRelease.AssertName("release");

            LabelRelease result = new LabelRelease();

            foreach (XAttribute attr in labelRelease.Attributes())
            {
                if (attr.Name == "id")
                {
                    result.Id = int.Parse(attr.Value);
                }
                else if (attr.Name == "status")
                {
                    result.Status = ParseReleaseStatus(attr.Value);
                }
                else
                {
                    throw new Exception("Unknown label release attribute: " + attr.Name);
                }
            }

            foreach (XElement e in labelRelease.Elements())
            {
                if (e.Name == "title")
                {
                    e.AssertOnlyText();
                    result.Title = e.Value;
                }
                else if (e.Name == "catno")
                {
                    e.AssertOnlyText();
                    result.CatalogNumber = e.Value;
                }
                else if (e.Name == "artist")
                {
                    e.AssertOnlyText();
                    result.Artist = e.Value;
                }
                else if (e.Name == "format")
                {
                    e.AssertOnlyText();
                    result.Format = e.Value;
                }
                else
                {
                    throw new Exception("Unknown label release element: " + e.Name);
                }
            }

            return result;
        }