コード例 #1
0
        protected bool IsAncestorLink(IElement element)
        {
            IElement parent = element.ParentElement;

            if (parent == null)
            {
                return(false);
            }
            List <INode> ancestors = element.Ancestors().ToList();

            return(ancestors.Any(ancestor => ancestor.NodeName == "BUTTON" ||
                                 ancestor.NodeName == "I" ||
                                 ancestor.NodeName == "A"));
        }
コード例 #2
0
        private void ReplaceNodeWithTemplateNode(IElement inNode, string inTemplateFileName)
        {
            //Clone node and get required content out of it
            var tmpNewNode = (IElement)inNode.Clone(true);

            foreach (var tmpClass in tmpNewNode.ClassList.ToList())
            {
                tmpNewNode.ClassList.Remove(tmpClass);
            }
            var tmpDict = new Dictionary <string, string>()
            {
                { "classes", string.Join(" ", inNode.ClassList) },
                { "contents", tmpNewNode.OuterHtml },
            };

            var tmpNewNodeHtml = Template(inTemplateFileName, tmpDict);

            inNode.Replace(CreateFromHtml(tmpNewNodeHtml, inNode.Ancestors().First() as IElement));
        }