public static ArchivedAlbumContract GetAllProperties(ArchivedAlbumVersion version) { var data = new ArchivedAlbumContract(); var xmlCache = new XmlCache <ArchivedAlbumContract>(); var thisVersion = xmlCache.Deserialize(version.Version, version.Data); data.DiscType = thisVersion.DiscType; data.Id = thisVersion.Id; data.MainPictureMime = thisVersion.MainPictureMime; data.TranslatedName = thisVersion.TranslatedName; DoIfExists(version, AlbumEditableFields.Artists, xmlCache, (v, doc) => SetArtists(data, v, doc)); DoIfExists(version, AlbumEditableFields.Description, xmlCache, v => { data.Description = v.Description; data.DescriptionEng = v.DescriptionEng; }); DoIfExists(version, AlbumEditableFields.Identifiers, xmlCache, v => data.Identifiers = v.Identifiers); DoIfExists(version, AlbumEditableFields.OriginalRelease, xmlCache, v => data.OriginalRelease = v.OriginalRelease); DoIfExists(version, AlbumEditableFields.Names, xmlCache, v => data.Names = v.Names); DoIfExists(version, AlbumEditableFields.Pictures, xmlCache, v => data.Pictures = v.Pictures); DoIfExists(version, AlbumEditableFields.PVs, xmlCache, v => data.PVs = v.PVs); DoIfExists(version, AlbumEditableFields.Tracks, xmlCache, v => data.Songs = v.Songs); DoIfExists(version, AlbumEditableFields.WebLinks, xmlCache, v => data.WebLinks = v.WebLinks); return(data); }
private static void SetArtists(ArchivedAlbumContract data, ArchivedAlbumContract 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 ArchivedArtistForAlbumContract { Id = int.Parse(e.Element("Id").Value), NameHint = e.Element("NameHint").Value }).ToArray(); } }
private static void SetArtists(ArchivedAlbumContract data, ArchivedAlbumContract 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 ArchivedArtistForAlbumContract { Id = int.Parse(e.Element("Id").Value), NameHint = e.Element("NameHint").Value }).ToArray(); } }
public static ArchivedAlbumContract GetAllProperties(ArchivedAlbumVersion version) { var data = new ArchivedAlbumContract(); var xmlCache = new XmlCache<ArchivedAlbumContract>(); var thisVersion = xmlCache.Deserialize(version.Version, version.Data); data.DiscType = thisVersion.DiscType; data.Id = thisVersion.Id; data.MainPictureMime = thisVersion.MainPictureMime; data.TranslatedName = thisVersion.TranslatedName; DoIfExists(version, AlbumEditableFields.Artists, xmlCache, (v, doc) => SetArtists(data, v, doc)); DoIfExists(version, AlbumEditableFields.Description, xmlCache, v => data.Description = v.Description); DoIfExists(version, AlbumEditableFields.Identifiers, xmlCache, v => data.Identifiers = v.Identifiers); DoIfExists(version, AlbumEditableFields.OriginalRelease, xmlCache, v => data.OriginalRelease = v.OriginalRelease); DoIfExists(version, AlbumEditableFields.Names, xmlCache, v => data.Names = v.Names); DoIfExists(version, AlbumEditableFields.Pictures, xmlCache, v => data.Pictures = v.Pictures); DoIfExists(version, AlbumEditableFields.PVs, xmlCache, v => data.PVs = v.PVs); DoIfExists(version, AlbumEditableFields.Tracks, xmlCache, v => data.Songs = v.Songs); DoIfExists(version, AlbumEditableFields.WebLinks, xmlCache, v => data.WebLinks = v.WebLinks); return data; }