예제 #1
0
        private static void ImplementTemplate(XmlDocument xml, XmlNode templateNode, string imageName, Dictionary <string, string> strings)
        {
            var newNode = templateNode.Clone();

            var childNodes = new List <XmlNode>();

            childNodes.AddRange(TemplateXmlGenerator.Flatten(newNode.ChildNodes));

            TemplateXmlGenerator.ReplaceText(strings, childNodes);

            newNode = xml.ImportNode(newNode, deep: true);
            childNodes.Clear();
            childNodes.AddRange(newNode.ChildNodes.Cast <XmlNode>());

            foreach (var childNode in childNodes)
            {
                templateNode.ParentNode.InsertBefore(childNode, templateNode);
            }
        }
예제 #2
0
        public static void GenerateDetails(string detailXmlFile, string destination, IEnumerable <string> imageNames, Dictionary <string, Dictionary <string, string> > replacementStrings, string title)
        {
            var xmlText = File.ReadAllText(detailXmlFile);

            foreach (var imageName in imageNames)
            {
                var xml = new XmlDocument();
                xml.LoadXml(xmlText);

                TemplateXmlGenerator.ReplaceText(replacementStrings[imageName], TemplateXmlGenerator.Flatten(xml.ChildNodes));

                TemplateXmlGenerator.ImplementTitle(xml, title);

                var destinationPath = Path.Combine(destination, imageName + ".xhtml");
                if (File.Exists(destinationPath))
                {
                    File.Delete(destinationPath);
                }
                xml.Save(destinationPath);
            }
        }