public static ReleaseArtist ReadReleaseArtist(XElement releaseArtist) { releaseArtist.AssertName("artist"); releaseArtist.AssertNoAttributes(); ReleaseArtist result = new ReleaseArtist(); foreach (XElement e in releaseArtist.Elements()) { if (e.Name == "name") { e.AssertOnlyText(); result.Name = e.Value; } else if (e.Name == "anv") { e.AssertOnlyText(); result.NameVariation = e.Value; } else if (e.Name == "join") { e.AssertOnlyText(); result.Join = e.Value; } else if (e.Name == "role") { if (e.IsEmpty) { continue; } throw new NotImplementedException(); } else if (e.Name == "tracks") { if (e.IsEmpty) { continue; } throw new NotImplementedException(); } else { throw new Exception("Unknown release artist element: " + e.Name); } } return(result); }
private ReleaseArtist ReadReleaseArtist(JObject source) { ReleaseArtist releaseArtist = new ReleaseArtist(); foreach (var item in source) { var v = item.Value; switch (item.Key) { case "join": releaseArtist.Join = v.Value <string>(); break; case "anv": releaseArtist.NameVariation = v.Value <string>(); break; case "name": releaseArtist.Name = v.Value <string>(); break; case "id": releaseArtist.Id = v.Value <int>(); break; case "role": releaseArtist.Role = v.Value <string>(); break; case "resource_url": break; case "tracks": releaseArtist.Tracks = v.Value <string>(); break; default: this.ThrowIfStrict("Unknown key: " + item.Key); break; } } return(releaseArtist); }
private void Merge() { foreach (MatchItem matchItem in matchItems) { matchItem.Item.Position = matchItem.Track; ReleaseArtist[] releaseArtists; if (matchItem == null || matchItem.Source == null || matchItem.Source.Artists == null) { releaseArtists = new ReleaseArtist[0]; } else { releaseArtists = matchItem.Source.Artists; } bool matchNames = Enumerable.SequenceEqual( matchItem.Item.Artists.Select(a => a.Artist.Name), releaseArtists.Select(a => a.Aggregate.NameVariationFixed)); bool matchJoins = Enumerable.SequenceEqual( matchItem.Item.Artists.Select(a => a.JoinString), releaseArtists.Select(a => a.Join)); if (!matchNames || !matchJoins) { matchItem.Item.Artists.Clear(); foreach (ReleaseArtist releaseArtist in releaseArtists) { matchItem.Item.Artists.Add(new Engine.Entities.TrackArtist() { Artist = this.collectionManager.GetOrCreateArtist(releaseArtist.Aggregate.NameVariationFixed), JoinString = releaseArtist.Join }); } matchItem.Item.JoinedArtists = releaseArtists.JoinFixed(); } matchItem.Item.Title = matchItem.Title; } }
public static ReleaseArtist ReadReleaseArtist(XElement releaseArtist) { releaseArtist.AssertName("artist"); releaseArtist.AssertNoAttributes(); ReleaseArtist result = new ReleaseArtist(); foreach (XElement e in releaseArtist.Elements()) { if (e.Name == "name") { e.AssertOnlyText(); result.Name = e.Value; } else if (e.Name == "anv") { e.AssertOnlyText(); result.NameVariation = e.Value; } else if (e.Name == "join") { e.AssertOnlyText(); result.Join = e.Value; } else if (e.Name == "role") { if (e.IsEmpty) { continue; } throw new NotImplementedException(); } else if (e.Name == "tracks") { if (e.IsEmpty) { continue; } throw new NotImplementedException(); } else { throw new Exception("Unknown release artist element: " + e.Name); } } return result; }
private ReleaseArtist ReadReleaseArtist() { this.XmlReader.AssertElementStart("artist"); ReleaseArtist artist = new ReleaseArtist(); while (true) { this.XmlReader.AssertRead(); if (this.XmlReader.IsElementEnd("artist")) { break; } if (this.XmlReader.IsElementStart("name")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); artist.Name = this.XmlReader.ReadContentAsString(); } } else if (this.XmlReader.IsElementStart("anv")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); artist.NameVariation = this.XmlReader.ReadContentAsString(); } } else if (this.XmlReader.IsElementStart("join")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); artist.Join = this.XmlReader.ReadContentAsString(); } } else if (this.XmlReader.IsElementStart("id")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); artist.Id = this.XmlReader.ReadContentAsInt(); } } else if (this.XmlReader.IsElementStart("role")) { this.XmlReader.AssertEmptyElement(); } else if (this.XmlReader.IsElementStart("tracks")) { this.XmlReader.AssertEmptyElement(); } else { this.ThrowInvalidFormatException(); } } return(artist); }
private ReleaseArtist ReadReleaseArtist() { this.XmlReader.AssertElementStart("artist"); ReleaseArtist artist = new ReleaseArtist(); while (true) { this.XmlReader.AssertRead(); if (this.XmlReader.IsElementEnd("artist")) { break; } if (this.XmlReader.IsElementStart("name")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); artist.Name = this.XmlReader.ReadContentAsString(); } } else if (this.XmlReader.IsElementStart("anv")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); artist.NameVariation = this.XmlReader.ReadContentAsString(); } } else if (this.XmlReader.IsElementStart("join")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); artist.Join = this.XmlReader.ReadContentAsString(); } } else if (this.XmlReader.IsElementStart("id")) { if (!this.XmlReader.IsEmptyElement) { this.XmlReader.AssertRead(); artist.Id = this.XmlReader.ReadContentAsInt(); } } else if (this.XmlReader.IsElementStart("role")) { this.XmlReader.AssertEmptyElement(); } else if (this.XmlReader.IsElementStart("tracks")) { this.XmlReader.AssertEmptyElement(); } else { this.ThrowInvalidFormatException(); } } return artist; }
private ReleaseArtist ReadReleaseArtist(JObject source) { ReleaseArtist releaseArtist = new ReleaseArtist(); foreach (var item in source) { var v = item.Value; switch (item.Key) { case "join": releaseArtist.Join = v.Value<string>(); break; case "anv": releaseArtist.NameVariation = v.Value<string>(); break; case "name": releaseArtist.Name = v.Value<string>(); break; case "id": releaseArtist.Id = v.Value<int>(); break; case "role": releaseArtist.Role = v.Value<string>(); break; case "resource_url": break; case "tracks": releaseArtist.Tracks = v.Value<string>(); break; default: this.ThrowIfStrict("Unknown key: " + item.Key); break; } } return releaseArtist; }