Example #1
0
        private static void GetMatchingNodes(INode node, string[] nodePath, int cur, IList <INode> res)
        {
            if (cur < 0 || cur >= nodePath.Length)
            {
                return;
            }
            bool   last = (cur == nodePath.Length - 1);
            string name = nodePath[cur];

            if (node.HasChildNodes())
            {
                INodeList children = node.GetChildNodes();
                for (int i = 0; i < children.GetLength(); i++)
                {
                    INode c = children.Item(i);
                    if (name.Equals(c.GetNodeName()))
                    {
                        if (last)
                        {
                            res.Add(c);
                        }
                        else
                        {
                            GetMatchingNodes(c, nodePath, cur + 1, res);
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Returns the first element within the document (using depth-first pre-order traversal
        /// of the document's nodes) that matches the specified group of selectors.
        /// </summary>
        /// <param name="elements">The elements to take as source.</param>
        /// <param name="selector">A selector object.</param>
        /// <returns>An element object.</returns>
        public static IElement QuerySelector(this INodeList elements, ISelector selector)
        {
            for (int i = 0; i < elements.Length; i++)
            {
                var element = elements[i] as IElement;

                if (element != null)
                {
                    if (selector.Match(element))
                    {
                        return(element);
                    }

                    if (!element.HasChildNodes)
                    {
                        continue;
                    }

                    element = QuerySelector(element.ChildNodes, selector);

                    if (element != null)
                    {
                        return(element);
                    }
                }
            }

            return(null);
        }
Example #3
0
        /// <summary>Collects all option elements that are child nodes (including inside optgroups).</summary>
        public static void CollectOptions(Node parent, INodeList hoc)
        {
            if (parent.childNodes_ == null)
            {
                return;
            }

            // For each child node..
            for (int i = 0; i < parent.childNodes_.length; i++)
            {
                // Get it:
                Node child = parent.childNodes_[i];

                // Option?
                if (child is HtmlOptionElement)
                {
                    hoc.push(child);
                    continue;
                }

                if (child.childNodes_ != null)
                {
                    // Go recursive:
                    CollectOptions(child, hoc);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Returns a NodeList of elements with the given tag name. The complete document is searched, including the root node.
        /// </summary>
        /// <param name="elements">The elements to take as source.</param>
        /// <param name="tagName">A string representing the name of the elements. The special string "*" represents all elements.</param>
        /// <returns>A NodeList of found elements in the order they appear in the tree.</returns>
        public static HtmlElementCollection GetElementsByTagName(this INodeList elements, String tagName)
        {
            var result = new List <IElement>();

            elements.GetElementsByTagName(tagName != "*" ? tagName : null, result);
            return(new HtmlElementCollection(result));
        }
Example #5
0
 /// <summary>
 /// 过滤标签集合
 /// </summary>
 /// <param name="nodes"></param>
 protected virtual void FiltersTags(INodeList nodes)
 {
     if (nodes == null)
     {
         return;
     }
     for (int i = 0; i < nodes.Length; i++)
     {
         var node = nodes[i];
         if (node is IElement element)
         {
             FiltesTag(element);
         }
         else
         {
             if (node.NodeType == NodeType.Comment)
             {
                 node.RemoveFromParent();
             }
         }
         if (node.Parent == null)
         {
             i--;
         }
     }
 }
Example #6
0
        /// <summary>
        /// Returns a NodeList of elements with the given tag name. The complete document is searched, including the root node.
        /// </summary>
        /// <param name="elements">The elements to take as source.</param>
        /// <param name="tagName">A string representing the name of the elements. The special string "*" represents all elements.</param>
        /// <returns>A NodeList of found elements in the order they appear in the tree.</returns>
        public static HtmlElementCollection GetElementsByTagName(this INodeList elements, String tagName)
        {
            var result = new List <IElement>();

            elements.GetElementsByTagName(tagName.Is(Keywords.Asterisk) ? null : tagName, result);
            return(new HtmlElementCollection(result));
        }
Example #7
0
 public TypeDeclaration(string name, TypeSyntax baseType, INodeList <TypeSyntax> implements, INodeList <MemberDeclaration> members) : base(DeclarationType.Class)
 {
     Name       = name;
     BaseType   = baseType;
     Implements = implements;
     Members    = members;
 }
Example #8
0
        /// <summary>
        /// Returns a list of elements with the given tag name belonging to the given namespace.
        /// The complete document is searched, including the root node.
        /// </summary>
        /// <param name="elements">The elements to take as source.</param>
        /// <param name="namespaceUri">The namespace URI of elements to look for.</param>
        /// <param name="localName">Either the local name of elements to look for or the special value "*", which matches all elements.</param>
        /// <returns>A NodeList of found elements in the order they appear in the tree.</returns>
        public static HtmlCollection <IElement> GetElementsByTagName(this INodeList elements, String namespaceUri, String localName)
        {
            var result = new List <IElement>();

            elements.GetElementsByTagName(namespaceUri, localName.Is(Keywords.Asterisk) ? null : localName, result);
            return(new HtmlCollection <IElement>(result));
        }
Example #9
0
        /// <summary>Gets all inputs from the given element, adding the results to the given list.</summary>
        /// <param name="results">The list that all results are added to.</param>
        /// <param name="element">The element to check.</param>
        public static void GetAllInputs(INodeList results, HtmlElement element, InputSearchMode mode)
        {
            NodeList kids = element.childNodes_;

            if (kids == null)
            {
                return;
            }

            for (int i = 0; i < kids.length; i++)
            {
                HtmlElement child = kids[i] as HtmlElement;

                if (child == null || child.Tag == "form")
                {
                    // Don't go into child forms.
                    continue;
                }

                if (
                    (mode == InputSearchMode.Submittable && child.IsFormSubmittable) ||
                    (mode == InputSearchMode.Listed && child.IsFormListed) ||
                    (mode == InputSearchMode.Resettable && child.IsFormResettable)
                    )
                {
                    results.push(child);
                }
                else
                {
                    GetAllInputs(results, child, mode);
                }
            }
        }
Example #10
0
        /// <summary>
        /// Given a path to a file containing a list of SsurgeonPatterns, returns
        /// TODO: deal with resources
        /// </summary>
        /// <exception cref="System.Exception"/>
        public virtual IList <SsurgeonPattern> ReadFromFile(File file)
        {
            IList <SsurgeonPattern> retList = new List <SsurgeonPattern>();
            IDocument doc          = DocumentBuilderFactory.NewInstance().NewDocumentBuilder().Parse(file);
            INodeList patternNodes = doc.GetElementsByTagName(SsurgeonPattern.SsurgeonElemTag);

            for (int i = 0; i < patternNodes.GetLength(); i++)
            {
                INode node = patternNodes.Item(i);
                if (node.GetNodeType() == NodeConstants.ElementNode)
                {
                    IElement        elt     = (IElement)node;
                    SsurgeonPattern pattern = SsurgeonPatternFromXML(elt);
                    retList.Add(pattern);
                }
            }
            INodeList resourceNodes = doc.GetElementsByTagName(SsurgeonPattern.ResourceTag);

            for (int i_1 = 0; i_1 < resourceNodes.GetLength(); i_1++)
            {
                INode node = patternNodes.Item(i_1);
                if (node.GetNodeType() == NodeConstants.ElementNode)
                {
                    IElement         resourceElt = (IElement)node;
                    SsurgeonWordlist wlRsrc      = new SsurgeonWordlist(resourceElt);
                    AddResource(wlRsrc);
                }
            }
            return(retList);
        }
Example #11
0
        /// <summary>
        /// Given the root Element for a SemgrexPattern (SSURGEON_ELEM_TAG), converts
        /// it into its corresponding SemgrexPattern object.
        /// </summary>
        /// <exception cref="System.Exception"/>
        public static SsurgeonPattern SsurgeonPatternFromXML(IElement elt)
        {
            string          uid            = GetTagText(elt, SsurgeonPattern.UidElemTag);
            string          notes          = GetTagText(elt, SsurgeonPattern.NotesElemTag);
            string          semgrexString  = GetTagText(elt, SsurgeonPattern.SemgrexElemTag);
            SemgrexPattern  semgrexPattern = SemgrexPattern.Compile(semgrexString);
            SsurgeonPattern retPattern     = new SsurgeonPattern(uid, semgrexPattern);

            retPattern.SetNotes(notes);
            INodeList editNodes = elt.GetElementsByTagName(SsurgeonPattern.EditListElemTag);

            for (int i = 0; i < editNodes.GetLength(); i++)
            {
                INode node = editNodes.Item(i);
                if (node.GetNodeType() == NodeConstants.ElementNode)
                {
                    IElement editElt = (IElement)node;
                    string   editVal = GetEltText(editElt);
                    retPattern.AddEdit(Edu.Stanford.Nlp.Semgraph.Semgrex.Ssurgeon.Ssurgeon.ParseEditLine(editVal));
                }
            }
            // If predicate available, parse
            IElement predElt = GetFirstTag(elt, SsurgeonPattern.PredicateTag);

            if (predElt != null)
            {
                ISsurgPred pred = AssemblePredFromXML(GetFirstChildElement(predElt));
                retPattern.SetPredicate(pred);
            }
            return(retPattern);
        }
 private void ConvertContentToText(INodeList node, TextWriter outText)
 {
     foreach (var subnode in node)
     {
         ConvertToText(subnode, outText);
     }
 }
Example #13
0
        /// <summary>
        /// Returns the first element within the document (using depth-first pre-order traversal
        /// of the document's nodes) that matches the specified group of selectors.
        /// </summary>
        /// <param name="elements">The elements to take as source.</param>
        /// <param name="selectors">A string containing one or more CSS selectors separated by commas.</param>
        /// <returns>An element object.</returns>
        public static IElement QuerySelector(this INodeList elements, String selectors)
        {
            var sg = CssParser.Default.ParseSelector(selectors);

            Validate(sg);
            return(elements.QuerySelector(sg));
        }
Example #14
0
        /// <summary>
        /// Visits all elements of a list and returns either the original or a new collection if any of the elements
        /// were modified.<para/>
        /// If the result of visiting a given element is null, that element will be excluded from the resulting list.
        /// </summary>
        /// <typeparam name="T">The type of element the list contains.</typeparam>
        /// <param name="list">The list of elements to visit.</param>
        /// <param name="elementVisitor">A function that visits each element.</param>
        /// <returns></returns>
        internal static IReadOnlyList <T> VisitList <T>(INodeList <T> list, Func <T, T> elementVisitor)
        {
            var  newItems = new List <T>(list.Count);
            bool modified = false;

            foreach (var item in list)
            {
                var newItem = elementVisitor(item);

                if (!Equals(newItem, item))
                {
                    modified = true;

                    if (newItem != null)
                    {
                        newItems.Add(newItem);
                    }
                }
                else
                {
                    newItems.Add(newItem);
                }
            }

            //If our list was modified, no point in wrapping it as INodeList<T> now; that'll happen when the list is incorporated into a TreeOrphan or TreeNode
            if (modified)
            {
                return(newItems.ToReadOnly());
            }

            return(list);
        }
Example #15
0
        /// <summary>
        /// Returns a list of elements with the given tag name belonging to the given namespace.
        /// The complete document is searched, including the root node.
        /// </summary>
        /// <param name="elements">The elements to take as source.</param>
        /// <param name="namespaceUri">The namespace URI of elements to look for.</param>
        /// <param name="localName">Either the local name of elements to look for or the special value "*", which matches all elements.</param>
        /// <returns>A NodeList of found elements in the order they appear in the tree.</returns>
        public static HtmlElementCollection GetElementsByTagNameNS(this INodeList elements, String namespaceUri, String localName)
        {
            var result = new List <IElement>();

            elements.GetElementsByTagNameNS(namespaceUri, localName != "*" ? localName : null, result);
            return(new HtmlElementCollection(result));
        }
Example #16
0
        public void ChangeEvent()
        {
            var dom = TestDom("TestHtml");

            INodeList list = dom["#hlinks-user > span:eq(1)"][0].ChildNodes;

            IDomObject changedNode = null;

            list.OnChanged += (sender, e) =>
            {
                changedNode = e.Node;
            };

            dom[".badge3"].Remove();
            Assert.AreEqual(null, changedNode);

            var nodeToRemove = dom[".badge2"][0];

            nodeToRemove.Remove();
            Assert.AreEqual(nodeToRemove, changedNode);

            var nodeToAdd = dom["<div id=test />"][0];

            dom["[title='2 silver badges']"].Append(nodeToAdd);

            Assert.AreEqual(nodeToAdd, changedNode);
        }
Example #17
0
        private static void GetMatchingNodes(INode node, Pattern[] nodePath, int cur, IList <INode> res)
        {
            if (cur < 0 || cur >= nodePath.Length)
            {
                return;
            }
            bool      last     = (cur == nodePath.Length - 1);
            Pattern   pattern  = nodePath[cur];
            INodeList children = node.GetChildNodes();

            for (int i = 0; i < children.GetLength(); i++)
            {
                INode c = children.Item(i);
                if (pattern.Matcher(c.GetNodeName()).Matches())
                {
                    if (last)
                    {
                        res.Add(c);
                    }
                    else
                    {
                        GetMatchingNodes(c, nodePath, cur + 1, res);
                    }
                }
            }
        }
Example #18
0
        /// <summary>
        /// Returns a list of the elements within the document (using depth-first pre-order traversal
        /// of the document's nodes) that matches the selector.
        /// </summary>
        /// <param name="elements">The elements to take as source.</param>
        /// <param name="selector">A selector object.</param>
        /// <returns>A HTMLCollection with all elements that match the selection.</returns>
        public static HtmlElementCollection QuerySelectorAll(this INodeList elements, ISelector selector)
        {
            var result = new List <IElement>();

            elements.QuerySelectorAll(selector, result);
            return(new HtmlElementCollection(result));
        }
Example #19
0
        private void LoadChildren(TreeNodeCollection where, INode node)
        {
            TreeNode  t;
            INodeList nodes = node.ChildNodes;

            foreach (INode child in nodes)
            {
                string s = Enum.GetName(typeof(NodeType), child.Type);
                switch (child.Type)
                {
                case NodeType.Attribute:
                    t = where.Add(nodeList.Count.ToString(), nodeList.Count.ToString() + "\t" + s + ":" + child.LocalName + "\t" + child.Value + "\t" + child.GetHashCode());
                    nodeList.Add(child);
                    break;

                case NodeType.Element:
                    t = where.Add(nodeList.Count.ToString(), nodeList.Count.ToString() + "\t" + s + ":" + child.LocalName + "\t" + child.GetHashCode());
                    nodeList.Add(child as IElement);
                    LoadChildren(t.Nodes, child);
                    break;

                case NodeType.Text:
                    t = where.Add(nodeList.Count.ToString(), nodeList.Count.ToString() + "\t" + s + ":" + child.Value + "\t" + child.GetHashCode());
                    nodeList.Add(child);
                    break;

                default:
                    t = where.Add(nodeList.Count.ToString(), nodeList.Count.ToString() + "\t" + s + "\t" + child.GetHashCode());
                    nodeList.Add(child);
                    break;
                }
                t.ContextMenu = popupmenu;
            }
        }
Example #20
0
        /// <summary>
        /// Returns a NodeList of elements with the given tag name. The complete document is searched, including the root node.
        /// </summary>
        /// <param name="elements">The elements to take as source.</param>
        /// <param name="tagName">A string representing the name of the elements. The special string "*" represents all elements.</param>
        /// <returns>A NodeList of found elements in the order they appear in the tree.</returns>
        public static IHtmlCollection <IElement> GetElementsByTagName(this INodeList elements, String tagName)
        {
            var result = new List <IElement>();

            elements.GetElementsByTagName(tagName is "*" ? null : tagName, result);
            return(new HtmlCollection <IElement>(result));
        }
        private List <LotteryDrawResult> GetScrapeResults(LotteryDetails lotteryDetails, IHtmlDocument document)
        {
            List <LotteryDrawResult> lotteryDrawResultArr = new List <LotteryDrawResult>();
            IEnumerable <IElement>   tableElement         = null;

            tableElement = document.All.Where(x => x.ClassName == "Grid search-lotto-result-table" &&
                                              x.Id == "cphContainer_cpContent_GridView1");
            if (tableElement.Any())
            {
                IElement tbody = tableElement.First();
                foreach (INode node in tbody.ChildNodes)
                {
                    foreach (INode tr in node.ChildNodes.Skip(1))
                    {
                        INodeList tds = tr.ChildNodes;
                        LotteryDrawResultSetup setup = new LotteryDrawResultSetup();
                        if (tr.ChildNodes.Length >= 5)
                        {
                            setup.PutNumberSequence(tr.ChildNodes[2].TextContent);
                            setup.DrawDate   = DateTime.ParseExact(tr.ChildNodes[3].TextContent, "M/d/yyyy", CultureInfo.InvariantCulture);
                            setup.JackpotAmt = double.Parse(tr.ChildNodes[4].TextContent);
                            setup.Winners    = int.Parse(tr.ChildNodes[5].TextContent);
                            setup.GameCode   = lotteryDetails.GameCode;
                            lotteryDrawResultArr.Add(setup);
                        }
                    }
                }
            }
            return(lotteryDrawResultArr);
        }
Example #22
0
        /// <summary>
        /// Returns the first element within the document (using depth-first pre-order traversal
        /// of the document's nodes) that matches the specified group of selectors.
        /// </summary>
        /// <param name="elements">The elements to take as source.</param>
        /// <param name="selector">A selector object.</param>
        /// <returns>An element object.</returns>
        public static IElement?QuerySelector(this INodeList elements, ISelector selector)
        {
            for (var i = 0; i < elements.Length; i++)
            {
                if (elements[i] is IElement element)
                {
                    if (selector.Match(element))
                    {
                        return(element);
                    }

                    if (element.HasChildNodes)
                    {
                        element = QuerySelector(element.ChildNodes, selector) !;

                        if (element != null)
                        {
                            return(element);
                        }
                    }
                }
            }

            return(null);
        }
        /// <summary>Read parse trees from a Reader.</summary>
        /// <param name="filename"/>
        /// <param name="in">
        /// The
        /// <c>Reader</c>
        /// </param>
        /// <param name="simplifiedTagset">
        /// If `true`, convert part-of-speech labels to a
        /// simplified version of the EAGLES tagset, where the tags do not
        /// include extensive morphological analysis
        /// </param>
        /// <param name="aggressiveNormalization">
        /// Perform aggressive "normalization"
        /// on the trees read from the provided corpus documents:
        /// split multi-word tokens into their constituent words (and
        /// infer parts of speech of the constituent words).
        /// </param>
        /// <param name="retainNER">
        /// Retain NER information in preterminals (for later
        /// use in `MultiWordPreprocessor) and add NER-specific
        /// parents to single-word NE tokens
        /// </param>
        /// <param name="detailedAnnotations">
        /// Retain detailed tree node annotations. These
        /// annotations on parse tree constituents may be useful for
        /// e.g. training a parser.
        /// </param>
        public SpanishXMLTreeReader(string filename, Reader @in, bool simplifiedTagset, bool aggressiveNormalization, bool retainNER, bool detailedAnnotations)
        {
            // Constituent annotations
            ITreebankLanguagePack tlp = new SpanishTreebankLanguagePack();

            this.simplifiedTagset    = simplifiedTagset;
            this.detailedAnnotations = detailedAnnotations;
            stream         = new ReaderInputStream(@in, tlp.GetEncoding());
            treeFactory    = new LabeledScoredTreeFactory();
            treeNormalizer = new SpanishTreeNormalizer(simplifiedTagset, aggressiveNormalization, retainNER);
            DocumentBuilder parser = XMLUtils.GetXmlParser();

            try
            {
                IDocument xml  = parser.Parse(stream);
                IElement  root = xml.GetDocumentElement();
                sentences = root.GetElementsByTagName(NodeSent);
                sentIdx   = 0;
            }
            catch (SAXException e)
            {
                log.Info("Parse exception while reading " + filename);
                Sharpen.Runtime.PrintStackTrace(e);
            }
            catch (IOException e)
            {
                Sharpen.Runtime.PrintStackTrace(e);
            }
        }
 public void DepthFirstSearch(TileBoard inputBoard)
 {
     openNodes = new NodeStack();
     Start(inputBoard);
     Console.WriteLine("Depth First Search: ");
     solution.Print();
     Console.WriteLine("----------------------------");
 }
 /// <summary>
 /// Returns a list of the elements within the rendered fragment or component under test,
 /// (using depth-first pre-order traversal of the document's nodes) that match the specified group of selectors.
 /// </summary>
 /// <param name="selector">The group of selectors to use.</param>
 /// <param name="nodelist">The elements to search within</param>
 public static IHtmlCollection <IElement> FindAll(this INodeList nodelist, string selector)
 {
     if (nodelist is null)
     {
         throw new ArgumentNullException(nameof(nodelist));
     }
     return(nodelist.QuerySelectorAll(selector));
 }
Example #26
0
 public void DepthLimitedSearch(TileBoard inputBoard)
 {
     openNodes = new NodeDepthStack(27, false);
     Start(inputBoard);
     Console.WriteLine("Depth Limited Search: (with a depth limit of 27)");
     solution.Print();
     Console.WriteLine("----------------------------");
 }
Example #27
0
 public void DepthFirstSearch(TileBoard inputBoard)
 {
     openNodes = new NodeStack();
     Start(inputBoard);
     Console.WriteLine("Depth First Search: ");
     solution.Print();
     Console.WriteLine("----------------------------");
 }
Example #28
0
 public void BreadthFirstSearch(TileBoard inputBoard)
 {
     openNodes = new NodeQueue();
     Start(inputBoard);
     Console.WriteLine("Breadth First Search: ");
     solution.Print();
     Console.WriteLine("----------------------------");
 }
Example #29
0
        public static IList <IElement> QuerySelectorAll(this INodeList elements, ISelector selector)
        {
            List <IElement> list = new List <IElement>();

            elements.QuerySelectorAll(selector, list);

            return(list);
        }
 /// <summary>
 /// Returns the first element within this element (using depth-first pre-order traversal
 /// of the document's nodes) that matches the specified group of selectors.
 /// </summary>
 /// <param name="selector">The group of selectors to use.</param>
 /// <param name="nodelist">The elements to search within</param>
 public static IElement Find(this INodeList nodelist, string selector)
 {
     if (nodelist is null)
     {
         throw new ArgumentNullException(nameof(nodelist));
     }
     return(nodelist.QuerySelector(selector));
 }
Example #31
0
 internal Node(XmlNode node)
 {
     thisNode          = node;
     thisAttributeList = null;
     thisChildNodeList = null;
     thisParentNode    = null;
     thisFirstChild    = null;
 }
 public void DepthLimitedSearch(TileBoard inputBoard)
 {
     openNodes = new NodeDepthStack(27, false);
     Start(inputBoard);
     Console.WriteLine("Depth Limited Search: (with a depth limit of 27)");
     solution.Print();
     Console.WriteLine("----------------------------");
 }
 public void BreadthFirstSearch(TileBoard inputBoard)
 {
     openNodes = new NodeQueue();
     Start(inputBoard);
     Console.WriteLine("Breadth First Search: ");
     solution.Print();
     Console.WriteLine("----------------------------");
 }
 public void IterativeDeepeningSearch(TileBoard inputBoard)
 {
     var dataStructure = new NodeDepthStack(1, true);
     openNodes = dataStructure;
     Start(inputBoard);
     Console.WriteLine("Iterative Deepening Search: (Final depth was " + dataStructure.Depth + " )");
     solution.Print();
     Console.WriteLine("----------------------------");
 }
Example #35
0
 public static MutationRecord ChildList(INode target, INodeList addedNodes = null, INodeList removedNodes = null, INode previousSibling = null, INode nextSibling = null)
 {
     return new MutationRecord
     {
         Type = ChildListType,
         Target = target,
         Added = addedNodes,
         Removed = removedNodes,
         PreviousSibling = previousSibling,
         NextSibling = nextSibling
     };
 }
        public void BidirectionalSearch(TileBoard inputBoard)
        {
            bidirectional = true;

            openNodes = new NodeQueue();
            openNodesReverse = new NodeQueue();

            Start(inputBoard);
            Console.WriteLine("Bidirectional Search: ");
            solution.Print();
            Console.WriteLine("----------------------------");

            bidirectional = false;
        }
        private void UpgradeChildren(INodeList openList,BoardNode visitedNode)
        {
            return;

            foreach (var node in visitedNodes.Where(node => node.Value.Previous == visitedNode))
            {
                node.Value.Cost = visitedNode.Cost + 1;
                if (openList.Upgrade(node.Value))
                    UpgradeChildren(openList, node.Value);
            }
        }
Example #38
0
 public CqXmlNodeList(XmlDocument xmlDocument, INodeList nodeList)
 {
     NodeList = nodeList;
     XmlDocument = xmlDocument;
 }
Example #39
0
 public void Concat(INodeList nodes)
 {
     foreach (Node n in nodes)
         Add(n);
 }
Example #40
0
 /// <summary>
 /// Eventargs used when nodes has been added to a Node.
 /// </summary>
 /// <param name="addedNodes">The nodes which have been added.</param>
 /// <param name="firstAddedNodeIndex">The index of the first Node added.</param>
 public NodesAddedEventArgs(INodeList addedNodes, int firstAddedNodeIndex)
 {
     m_addedNodes = addedNodes;
     m_firstAddedNodeIndex = firstAddedNodeIndex;
 }
Example #41
0
 /// <summary>
 /// Return the correct child from a list based on an index, and the current "FromLast" setting
 /// </summary>
 /// <param name="nodeList"></param>
 /// <param name="index"></param>
 /// <returns></returns>
 private IDomObject GetEffectiveChild(INodeList nodeList, int index)
 {
     return GetEffectiveChild(nodeList, index, FromLast);
 }
Example #42
0
        static void AssertArrayEqual(INodeList actual, INodeList expected)
        {
            Assert.AreEqual(expected.Length, actual.Length);

            for (int i = 0; i < expected.Length; i++)
                Assert.AreSame(expected[i], actual[i]);
        }
Example #43
0
 /// <summary>
 /// Eventargs used when nodes have been removed from a Node.
 /// </summary>
 /// <param name="removedNodes">The nodes which have been removed.</param>
 public NodesRemovedEventArgs(INodeList removedNodes)
 {
     m_removedNodes = removedNodes;
 }
Example #44
0
        /// <summary>
        /// Gets the true index based on an effective index. (Misnomer, consider changing, should be
        /// GetActualIndex)
        /// </summary>
        ///
        /// <param name="nodeList">
        /// The container to obtain children from
        /// </param>
        /// <param name="index">
        /// The index
        /// </param>
        /// <param name="fromLast">
        /// Count from the last element instead of the first.
        /// </param>
        ///
        /// <returns>
        /// The actual index.
        /// </returns>

        public static int GetEffectiveIndex(INodeList nodeList, int index, bool fromLast)
        {
            if (fromLast)
            {
                return nodeList.Length - index - 1;
            }
            else
            {
                return index;
            }
        }
Example #45
0
        // These methods are exposed because they are used elsewhere

        /// <summary>
        /// Return the correct child from a list based on an index, and the fromLast setting. That is, if fromLast is
        /// true, just return the child at "index." If not, return the child starting from the end at "index"
        /// </summary>
        ///
        /// <param name="nodeList">
        /// The container to obtain children from
        /// </param>
        /// <param name="index">
        /// The index
        /// </param>
        /// <param name="fromLast">
        /// Count from the last element instead of the first.
        /// </param>
        ///
        /// <returns>
        /// The effective child.
        /// </returns>

        public static IDomObject GetEffectiveChild(INodeList nodeList, int index, bool fromLast)
        {
            if (fromLast)
            {
                return nodeList[nodeList.Count - index - 1];
            }
            else
            {
                return nodeList[index];
            }
        }
Example #46
0
 /// <summary>
 /// Eventargs used when a Node is splitted from his parents
 /// </summary>
 /// <param name="originalParents">The parents before the splitting event.</param>
 public NodeSplittedEventArgs(INodeList originalParents)
 {
     m_originalParents = originalParents;
 }