public static ArtistRelease ReadArtistRelease(XElement artistRelease) { artistRelease.AssertName("release"); ArtistRelease result = new ArtistRelease(); foreach (XAttribute attr in artistRelease.Attributes()) { if (attr.Name == "id") { result.Id = int.Parse(attr.Value); } else if (attr.Name == "status") { result.Status = ParseReleaseStatus(attr.Value); } else if (attr.Name == "type") { result.Type = ParseArtistReleaseType(attr.Value); } else { throw new Exception("Unknown artist release attribute: " + attr.Name); } } foreach (XElement e in artistRelease.Elements()) { if (e.Name == "title") { e.AssertOnlyText(); result.Title = e.Value; } else if (e.Name == "format") { e.AssertOnlyText(); result.Format = e.Value; } else if (e.Name == "label") { e.AssertOnlyText(); result.Label = e.Value; } else if (e.Name == "year") { e.AssertOnlyText(); result.Year = int.Parse(e.Value); } else if (e.Name == "trackinfo") { e.AssertOnlyText(); result.TrackInfo = e.Value; } else { throw new Exception("Unknown artist release element: " + e.Name); } } return result; }
public static ArtistRelease ReadArtistRelease(XElement artistRelease) { artistRelease.AssertName("release"); ArtistRelease result = new ArtistRelease(); foreach (XAttribute attr in artistRelease.Attributes()) { if (attr.Name == "id") { result.Id = int.Parse(attr.Value); } else if (attr.Name == "status") { result.Status = ParseReleaseStatus(attr.Value); } else if (attr.Name == "type") { result.Type = ParseArtistReleaseType(attr.Value); } else { throw new Exception("Unknown artist release attribute: " + attr.Name); } } foreach (XElement e in artistRelease.Elements()) { if (e.Name == "title") { e.AssertOnlyText(); result.Title = e.Value; } else if (e.Name == "format") { e.AssertOnlyText(); result.Format = e.Value; } else if (e.Name == "label") { e.AssertOnlyText(); result.Label = e.Value; } else if (e.Name == "year") { e.AssertOnlyText(); result.Year = int.Parse(e.Value); } else if (e.Name == "trackinfo") { e.AssertOnlyText(); result.TrackInfo = e.Value; } else { throw new Exception("Unknown artist release element: " + e.Name); } } return(result); }