public static StyleInfo FromXml(XmlNode configNode, StorageDirectory sharedImagesFolder, string productId) { var styleInfo = Empty(); styleInfo.Title = configNode.SelectSingleNode("./Title")?.InnerText ?? styleInfo.Title; foreach (var node in configNode.SelectNodes("./Tabs/Tab")?.OfType <XmlNode>().ToArray() ?? new XmlNode[] { }) { var id = node.Attributes?.OfType <XmlAttribute>() .FirstOrDefault(a => String.Equals(a.Name, "Id", StringComparison.OrdinalIgnoreCase))?.Value?.ToUpper(); switch (id) { case "IMAGE": styleInfo.Tab1 = ImageTabInfo.FromXml(node, new StorageDirectory(sharedImagesFolder.RelativePathParts.Merge(new[] { "product_images", productId }))); break; case "LAYOUT": styleInfo.Tab2 = LayoutTabInfo.FromXml(node, new StorageDirectory(sharedImagesFolder.RelativePathParts.Merge("layout_images"))); break; } } return(styleInfo); }
private StyleInfo() { Title = "style"; Tab1 = ImageTabInfo.Empty(); Tab2 = LayoutTabInfo.Empty(); }