public static ParseReleaseStatus ( string status ) : ReleaseStatus | ||
status | string | |
리턴 | ReleaseStatus |
private ReleaseVersion ReadReleaseVersion() { this.XmlReader.AssertElementStart("release"); ReleaseVersion version = new ReleaseVersion(); version.Id = int.Parse(this.XmlReader.GetAttribute("id")); version.Status = DataReader.ParseReleaseStatus(this.XmlReader.GetAttribute("status")); while (true) { this.XmlReader.AssertRead(); if (this.XmlReader.IsElementEnd("release")) { break; } if (this.XmlReader.IsElementStart("title")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); version.Title = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("format")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); version.Format = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("label")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); version.Label = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("catno")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); version.CatalogNumber = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("country")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); version.Country = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("released")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); version.ReleaseDate = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("thumb")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); version.Thumb = this.XmlReader.ReadContentAsString(); } else { this.ThrowInvalidFormatException(); } } return(version); }
private ReleaseVersion ReadReleaseVersion(JObject source) { ReleaseVersion version = new ReleaseVersion(); foreach (var item in source) { var v = item.Value; switch (item.Key) { case "thumb": version.Thumb = v.Value <string>(); break; case "title": version.Title = v.Value <string>(); break; case "main_release": version.MainRelease = v.Value <int>(); break; case "role": version.Role = v.Value <string>(); break; case "year": version.Year = v.Value <int>(); break; case "type": version.Type = ParseReleaseVersionType(v.Value <string>()); break; case "id": version.Id = v.Value <int>(); break; case "label": version.Label = v.Value <string>(); break; case "format": version.Format = v.Value <string>(); break; case "status": version.Status = DataReader.ParseReleaseStatus(v.Value <string>()); break; case "trackinfo": version.TrackInfo = v.Value <string>(); break; case "resource_url": break; default: this.ThrowIfStrict("Unknown key: " + item.Key); break; } } return(version); }
public Release ReadRelease() { this.XmlReader.AssertElementStart("release"); Release release = new Release(); release.Id = int.Parse(this.XmlReader.GetAttribute("id")); release.Status = DataReader.ParseReleaseStatus(this.XmlReader.GetAttribute("status")); while (true) { this.XmlReader.AssertRead(); if (this.XmlReader.IsElementEnd("release")) { break; } if (this.XmlReader.IsElementStart("images")) { release.Images = this.ReadImages(); } else if (this.XmlReader.IsElementStart("artists")) { release.Artists = this.ReadReleaseArtists(); } else if (this.XmlReader.IsElementStart("title")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); release.Title = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("labels")) { release.Labels = this.ReadReleaseLabels(); } else if (this.XmlReader.IsElementStart("extraartists")) { release.ExtraArtists = this.ReadExtraArtists(); } else if (this.XmlReader.IsElementStart("formats")) { release.Formats = this.ReadFormats(); } else if (this.XmlReader.IsElementStart("genres")) { release.Genres = this.ReadGenres(); } else if (this.XmlReader.IsElementStart("styles")) { release.Styles = this.ReadStyles(); } else if (this.XmlReader.IsElementStart("country")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); release.Country = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("released")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); release.ReleaseDate = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("notes")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); release.Notes = this.XmlReader.ReadContentAsString(); } else if (this.XmlReader.IsElementStart("master_id")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); release.MasterId = int.Parse(this.XmlReader.ReadContentAsString()); } else if (this.XmlReader.IsElementStart("data_quality")) { this.XmlReader.AssertNonEmptyElement(); this.XmlReader.AssertRead(); release.DataQuality = DataReader.ParseDataQuality(this.XmlReader.ReadContentAsString()); } else if (this.XmlReader.IsElementStart("tracklist")) { release.Tracklist = this.ReadTracklist(); } else if (this.XmlReader.IsElementStart("videos")) { release.Videos = this.ReadVideos(); } else if (this.XmlReader.IsElementStart("identifiers")) { release.Identifiers = this.ReadReleaseIdentifiers(); } else { this.ThrowInvalidFormatException(); } } return(release); }
public Release ReadRelease(JObject source) { Release release = new Release(); foreach (var item in source) { var v = item.Value; switch (item.Key) { case "id": release.Id = v.Value <int>(); break; case "status": release.Status = DataReader.ParseReleaseStatus(v.Value <string>()); break; case "videos": release.Videos = this.ReadReleaseVideos(v.Value <JArray>()); break; case "series": if (((JArray)v).Count != 0) { this.ThrowIfStrict("Unable to process \"series\" item."); } break; case "labels": release.Labels = this.ReadReleaseLabels(v.Value <JArray>()); break; case "year": // We skip year. Can extract it from release date. break; case "images": release.Images = this.ReadImages(v.Value <JArray>()); break; case "genres": release.Genres = v.ValueAsStringArray(); break; case "thumb": // We skip thumb. Can extract it from images. break; case "extraartists": release.ExtraArtists = this.ReadExtraArtists(v.Value <JArray>()); break; case "title": release.Title = v.Value <string>(); break; case "artists": release.Artists = this.ReadReleaseArtists(v.Value <JArray>()); break; case "master_id": release.MasterId = v.Value <int>(); break; case "tracklist": release.Tracklist = this.ReadReleaseTracklist(v.Value <JArray>()); break; case "styles": release.Styles = v.ValueAsStringArray(); break; case "released_formatted": // We skip released_formatted. Can extract it from released. break; case "released": release.ReleaseDate = v.Value <string>(); break; case "master_url": // We skip master_url. Can extract it from master_id. break; case "country": release.Country = v.Value <string>(); break; case "notes": release.Notes = v.Value <string>(); break; case "companies": release.Compaines = this.ReadCompanies(v.Value <JArray>()); break; case "uri": // TODO: implement model for this break; case "formats": release.Formats = this.ReadReleaseFormats(v.Value <JArray>()); break; case "resource_url": break; case "data_quality": release.DataQuality = DataReader.ParseDataQuality(v.Value <string>()); break; case "identifiers": release.Identifiers = this.ReadReleaseIdentifiers(v.Value <JArray>()); break; default: this.ThrowIfStrict("Unknown key: " + item.Key); break; } } return(release); }