public static ArchivedSongContract GetAllProperties(ArchivedSongVersion version) { var data = new ArchivedSongContract(); var xmlCache = new XmlCache <ArchivedSongContract>(); var thisVersion = xmlCache.Deserialize(version.Version, version.Data); data.Id = thisVersion.Id; data.LengthSeconds = thisVersion.LengthSeconds; data.NicoId = thisVersion.NicoId; data.Notes = thisVersion.Notes; data.NotesEng = thisVersion.NotesEng; data.OriginalVersion = thisVersion.OriginalVersion; data.PublishDate = thisVersion.PublishDate; data.ReleaseEvent = thisVersion.ReleaseEvent; data.SongType = thisVersion.SongType; data.TranslatedName = thisVersion.TranslatedName; DoIfExists(version, SongEditableFields.Albums, xmlCache, v => data.Albums = v.Albums); DoIfExists(version, SongEditableFields.Artists, xmlCache, (v, doc) => SetArtists(data, v, doc)); DoIfExists(version, SongEditableFields.Lyrics, xmlCache, v => data.Lyrics = v.Lyrics); DoIfExists(version, SongEditableFields.Names, xmlCache, v => data.Names = v.Names); DoIfExists(version, SongEditableFields.PVs, xmlCache, v => data.PVs = v.PVs); DoIfExists(version, SongEditableFields.WebLinks, xmlCache, v => data.WebLinks = v.WebLinks); return(data); }
private static void SetArtists(ArchivedSongContract data, ArchivedSongContract serialized, XDocument doc) { if (serialized.Artists != null && serialized.Artists.Any()) { data.Artists = serialized.Artists; } else { // For backwards compatibility var artistElems = doc.XPathSelectElements("//ArchivedAlbumContract/Artists/ObjectRefContract"); //.Elements("Artists").Elements("ObjectRefContract")); data.Artists = artistElems.Select(e => new ArchivedArtistForSongContract { Id = int.Parse(e.Element("Id").Value), NameHint = e.Element("NameHint").Value }).ToArray(); } }
private static void SetArtists(ArchivedSongContract data, ArchivedSongContract serialized, XDocument doc) { if (serialized.Artists != null && serialized.Artists.Any()) data.Artists = serialized.Artists; else { // For backwards compatibility var artistElems = doc.XPathSelectElements("//ArchivedAlbumContract/Artists/ObjectRefContract"); //.Elements("Artists").Elements("ObjectRefContract")); data.Artists = artistElems.Select(e => new ArchivedArtistForSongContract { Id = int.Parse(e.Element("Id").Value), NameHint = e.Element("NameHint").Value }).ToArray(); } }
public static ArchivedSongContract GetAllProperties(ArchivedSongVersion version) { var data = new ArchivedSongContract(); var xmlCache = new XmlCache<ArchivedSongContract>(); var thisVersion = xmlCache.Deserialize(version.Version, version.Data); data.Id = thisVersion.Id; data.LengthSeconds = thisVersion.LengthSeconds; data.NicoId = thisVersion.NicoId; data.Notes = thisVersion.Notes; data.OriginalVersion = thisVersion.OriginalVersion; data.SongType = thisVersion.SongType; data.TranslatedName = thisVersion.TranslatedName; DoIfExists(version, SongEditableFields.Artists, xmlCache, (v, doc) => SetArtists(data, v, doc)); DoIfExists(version, SongEditableFields.Lyrics, xmlCache, v => data.Lyrics = v.Lyrics); DoIfExists(version, SongEditableFields.Names, xmlCache, v => data.Names = v.Names); DoIfExists(version, SongEditableFields.PVs, xmlCache, v => data.PVs = v.PVs); DoIfExists(version, SongEditableFields.WebLinks, xmlCache, v => data.WebLinks = v.WebLinks); return data; }