Пример #1
0
        private static string GetNormalizedTranslationKey(TKeyRef tKeyRef)
        {
            string  text = "";
            XmlNode currentNode;

            for (currentNode = tKeyRef.node; currentNode != tKeyRef.defRootNode; currentNode = currentNode.ParentNode)
            {
                text = ((!(currentNode.Name == "li") && !treatAsList.Contains(currentNode.ParentNode)) ? ("." + currentNode.Name + text) : ("." + currentNode.ParentNode.ChildNodes.Cast <XmlNode>().FirstIndexOf((XmlNode n) => n == currentNode) + text));
            }
            return(tKeyRef.defName + text);
        }
Пример #2
0
        private static void ParseDefNode(XmlNode node)
        {
            string text = (from XmlNode n in node.ChildNodes
                           where n.Name == "defName"
                           select n.InnerText).FirstOrDefault();
            TKeyRef tKeyRefTemplate;

            if (!string.IsNullOrWhiteSpace(text))
            {
                tKeyRefTemplate             = default(TKeyRef);
                tKeyRefTemplate.defName     = text;
                tKeyRefTemplate.defTypeName = node.Name;
                tKeyRefTemplate.defRootNode = node;
                CrawlNodesRecursive(node);
            }
            void CrawlNodesRecursive(XmlNode n)
            {
                ProcessNode(n);
                foreach (XmlNode childNode in n.ChildNodes)
                {
                    CrawlNodesRecursive(childNode);
                }
            }

            void ProcessNode(XmlNode n)
            {
                XmlAttribute xmlAttribute;

                if (n.Attributes != null && (xmlAttribute = n.Attributes["TKey"]) != null)
                {
                    TKeyRef item = tKeyRefTemplate;
                    item.tKey     = xmlAttribute.Value;
                    item.node     = n;
                    item.tKeyPath = item.defName + "." + item.tKey;
                    keys.Add(item);
                }
            }
        }