/////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///
        /// </summary>
        /// <param name="result"></param>
        /// <param name="name"></param>
        /// <param name="searchChildren"></param>
        public void FindByName(CHtmlNodeCollection result, string name, int depth)
        {
            System.Diagnostics.Debug.Assert(result != null);
            System.Diagnostics.Debug.Assert(name != null);
            System.Diagnostics.Debug.Assert(depth >= 0);

            if (depth > 0)
            {
                name = name.Trim().ToLower();

                for (int index = 0, count = m_nodeList.Count; index < count; ++index)
                {
                    CHtmlNode node = m_nodeList[index];
                    if (node.NodeName.Equals(name))
                    {
                        result.Add(node);
                    }

                    if (depth > 1 && node is CHtmlElement)
                    {
                        ((CHtmlElement)node).Nodes.FindByName(result, name, depth - 1);
                    }
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///
        /// </summary>
        /// <param name="result"></param>
        /// <param name="name"></param>
        /// <param name="attributeName"></param>
        /// <param name="attributeValue"></param>
        /// <param name="searchChildren"></param>
        public void FindByNameAttributeValue(CHtmlNodeCollection result, string name, string attributeName, string attributeValue, bool searchChildren)
        {
            System.Diagnostics.Debug.Assert(result != null);
            System.Diagnostics.Debug.Assert(attributeName != null);

            attributeName = attributeName.Trim().ToLower();

            for (int index = 0, count = m_nodeList.Count; index < count; ++index)
            {
                CHtmlNode node = m_nodeList[index];

                if (node.NodeName.Equals(name) && node is IHtmlNodeHasAttribute)
                {
                    CHtmlAttribute attribute = ((IHtmlNodeHasAttribute)node).Attributes[attributeName];
                    if (attribute != null && attribute.Value == attributeValue)
                    {
                        result.Add(node);
                    }
                }

                if (searchChildren && node is CHtmlElement)
                {
                    ((CHtmlElement)node).Nodes.FindByNameAttributeValue(result, name, attributeName, attributeValue, searchChildren);
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="searchChildren"></param>
        /// <returns></returns>
        public CHtmlNode FindByNameFirstNode(string name, bool searchChildren)
        {
            System.Diagnostics.Debug.Assert(name != null);

            CHtmlNode result = null;

            name = name.Trim().ToLower();

            for (int index = 0, count = m_nodeList.Count; index < count; ++index)
            {
                CHtmlNode node = m_nodeList[index];
                if (node.NodeName.Equals(name))
                {
                    result = node;
                    if (result != null)
                    {
                        break;
                    }
                }

                if (searchChildren == true && node is CHtmlElement)
                {
                    result = ((CHtmlElement)node).Nodes.FindByNameFirstNode(name, searchChildren);
                    if (result != null)
                    {
                        break;
                    }
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public CHtmlNode GetCommonAncestor(CHtmlNode node)
        {
            System.Diagnostics.Debug.Assert(node != null);

            CHtmlNode commonAncestor = null;

            CHtmlNode thisParent = this;

            while (commonAncestor != null && thisParent != null)
            {
                CHtmlNode thatParent = node;
                while (commonAncestor != null && thatParent != null)
                {
                    if (thisParent == thatParent)
                    {
                        commonAncestor = thisParent;
                    }

                    thatParent = thatParent.Parent;
                }
                thisParent = thisParent.Parent;
            }

            return(commonAncestor);
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="depth"></param>
        /// <returns></returns>
        public CHtmlNode FindByNameFirstNode(string name, int depth)
        {
            System.Diagnostics.Debug.Assert(depth >= 0);

            CHtmlNode result = null;

            if (depth > 0)
            {
                name = name.Trim().ToLower();

                for (int index = 0, count = m_nodeList.Count; index < count; ++index)
                {
                    CHtmlNode node = m_nodeList[index];
                    if (node.NodeName.Equals(name))
                    {
                        result = node;
                        if (result != null)
                        {
                            break;
                        }
                    }

                    if (depth > 1 && node is CHtmlElement)
                    {
                        result = ((CHtmlElement)node).Nodes.FindByNameFirstNode(name, depth - 1);
                        if (result != null)
                        {
                            break;
                        }
                    }
                }
            }

            return(result);
        }
Exemplo n.º 6
0
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///
        /// </summary>
        protected CHtmlNode(CHtmlNode obj)
        {
            System.Diagnostics.Debug.Assert(obj != null);

            obj.AssertValid();

            m_parent     = obj.m_parent;
            m_nodeID     = obj.m_nodeID;
            m_bindObject = obj.m_bindObject;
        }
Exemplo n.º 7
0
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// 
        /// </summary>
        protected CHtmlNode(CHtmlNode obj)
        {
            System.Diagnostics.Debug.Assert(obj != null);

            obj.AssertValid();

            m_parent = obj.m_parent;
            m_nodeID = obj.m_nodeID;
            m_bindObject = obj.m_bindObject;
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///
        /// </summary>
        /// <param name="result"></param>
        public void GetDescendent(CHtmlNodeCollection result)
        {
            System.Diagnostics.Debug.Assert(result != null);

            for (int index = 0, count = m_nodeList.Count; index < count; ++index)
            {
                CHtmlNode node = m_nodeList[index];
                result.Add(node);
                if (node is CHtmlElement)
                {
                    ((CHtmlElement)node).Nodes.GetDescendent(result);
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///
        /// </summary>
        public void Clear()
        {
            // set node.Parent
            if (m_ownerNode != null)
            {
                for (int index = 0, count = m_nodeList.Count; index < count; ++index)
                {
                    CHtmlNode node = m_nodeList[index];
                    System.Diagnostics.Debug.Assert(m_ownerNode == node.Parent);
                    node.Parent = null;
                }
            }

            m_nodeList.Clear();
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///
        /// </summary>
        /// <param name="index"></param>
        public void RemoveAt(int index)
        {
            System.Diagnostics.Debug.Assert(index >= 0 && index < m_nodeList.Count);

            CHtmlNode node = m_nodeList[index];

            // set node.Parent
            if (m_ownerNode != null)
            {
                System.Diagnostics.Debug.Assert(m_ownerNode == node.Parent);
                node.Parent = null;
            }

            m_nodeList.RemoveAt(index);
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// This will add a node to the collection.
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public void Add(CHtmlNode node)
        {
            System.Diagnostics.Debug.Assert(node != null);

            // set node.Parent
            if (m_ownerNode != null)
            {
                if (node.Parent != null)
                {
                    int index = node.Parent.Nodes.IndexOf(node);
                    node.Parent.Nodes.m_nodeList.RemoveAt(index);
                }

                node.Parent = m_ownerNode;
            }

            m_nodeList.Add(node);
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// This will insert a node at the given position
        /// </summary>
        /// <param name="index">The position at which to insert the node.</param>
        /// <param name="node">The node to insert.</param>
        public void Insert(int index, CHtmlNode node)
        {
            System.Diagnostics.Debug.Assert(index >= 0 && index <= m_nodeList.Count);
            System.Diagnostics.Debug.Assert(node != null);

            // set node.Parent
            if (m_ownerNode != null)
            {
                if (node.Parent != null)
                {
                    node.Parent.Nodes.RemoveAt(node.Parent.Nodes.IndexOf(node));
                }

                node.Parent = m_ownerNode;
            }

            m_nodeList.Insert(index, node);
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///
        /// </summary>
        /// <param name="index"></param>
        /// <param name="count"></param>
        public void RemoveRange(int index, int count)
        {
            System.Diagnostics.Debug.Assert(index >= 0 && index < m_nodeList.Count);
            System.Diagnostics.Debug.Assert(count > 0);
            System.Diagnostics.Debug.Assert(index + count <= m_nodeList.Count);

            for (int scanIndex = index; scanIndex < index + count; ++scanIndex)
            {
                CHtmlNode node = m_nodeList[scanIndex];

                // set node.Parent
                if (m_ownerNode != null)
                {
                    System.Diagnostics.Debug.Assert(m_ownerNode == node.Parent);
                    node.Parent = null;
                }
            }

            m_nodeList.RemoveRange(index, count);
        }
Exemplo n.º 14
0
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// node의 부모여부
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public bool IsDescendentOf(CHtmlNode node)
        {
            System.Diagnostics.Debug.Assert(node != null);

            bool reault = false;

            CHtmlNode parent = m_parent;

            while (parent != null)
            {
                if (parent == node)
                {
                    reault = true;
                    break;
                }

                parent = parent.m_parent;
            }

            return(reault);
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        ///
        /// </summary>
        /// <param name="result"></param>
        /// <param name="name"></param>
        /// <param name="searchChildren"></param>
        public void FindByName(CHtmlNodeCollection result, string name, bool searchChildren)
        {
            System.Diagnostics.Debug.Assert(result != null);
            System.Diagnostics.Debug.Assert(name != null);

            name = name.Trim().ToLower();

            for (int index = 0, count = m_nodeList.Count; index < count; ++index)
            {
                CHtmlNode node = m_nodeList[index];
                if (node.NodeName.Equals(name))
                {
                    result.Add(node);
                }

                if (searchChildren == true && node is CHtmlElement)
                {
                    ((CHtmlElement)node).Nodes.FindByName(result, name, searchChildren);
                }
            }
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// This allows you to directly access the first element in this colleciton with the given name.
        /// If the node does not exist, this will return null.
        /// </summary>
        public CHtmlNode this[string name]
        {
            get
            {
                System.Diagnostics.Debug.Assert(name != null);

                name = name.Trim().ToLower();

                CHtmlNode result = null;

                for (int index = 0, count = m_nodeList.Count; index < count; ++index)
                {
                    CHtmlNode node = m_nodeList[index];
                    if (node.NodeName.Equals(name))
                    {
                        result = node;
                        break;
                    }
                }

                return(result);
            }
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// This will add a node to the collection.
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public void Add(CHtmlNode node)
        {
            System.Diagnostics.Debug.Assert(node != null);

            // set node.Parent
            if(m_ownerNode != null)
            {
                if(node.Parent != null)
                {
                    int index = node.Parent.Nodes.IndexOf(node);
                    node.Parent.Nodes.m_nodeList.RemoveAt(index);
                }

                node.Parent = m_ownerNode;
            }

            m_nodeList.Add(node);
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// This will insert a node at the given position
        /// </summary>
        /// <param name="index">The position at which to insert the node.</param>
        /// <param name="node">The node to insert.</param>
        public void Insert(int index, CHtmlNode node)
        {
            System.Diagnostics.Debug.Assert(index >= 0 && index <= m_nodeList.Count);
            System.Diagnostics.Debug.Assert(node != null);

            // set node.Parent
            if(m_ownerNode != null)
            {
                if(node.Parent != null)
                    node.Parent.Nodes.RemoveAt(node.Parent.Nodes.IndexOf(node));

                node.Parent = m_ownerNode;
            }

            m_nodeList.Insert(index, node);
        }
Exemplo n.º 19
0
 /////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// node의 자식여부.
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public bool IsAncestorOf(CHtmlNode node)
 {
     System.Diagnostics.Debug.Assert(node != null);
     return(node.IsDescendentOf(this));
 }
Exemplo n.º 20
0
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// node�� �θ𿩺�
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public bool IsDescendentOf(CHtmlNode node)
        {
            System.Diagnostics.Debug.Assert(node != null);

            bool reault = false;

            CHtmlNode parent = m_parent;
            while(parent != null)
            {
                if (parent == node)
                {
                    reault = true;
                    break;
                }

                parent = parent.m_parent;
            }

            return reault;
        }
Exemplo n.º 21
0
 /////////////////////////////////////////////////////////////////////////////////
 /// <summary>
 /// node�� �ڽĿ���.
 /// </summary>
 /// <param name="node"></param>
 /// <returns></returns>
 public bool IsAncestorOf(CHtmlNode node)
 {
     System.Diagnostics.Debug.Assert(node != null);
     return node.IsDescendentOf(this);
 }
Exemplo n.º 22
0
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// 
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public CHtmlNode GetCommonAncestor(CHtmlNode node)
        {
            System.Diagnostics.Debug.Assert(node != null);

            CHtmlNode commonAncestor = null;

            CHtmlNode thisParent = this;
            while(commonAncestor != null && thisParent != null)
            {
                CHtmlNode thatParent = node;
                while(commonAncestor != null && thatParent != null)
                {
                    if(thisParent == thatParent)
                      commonAncestor = thisParent;

                    thatParent = thatParent.Parent;
                }
                thisParent = thisParent.Parent;
            }

            return commonAncestor;
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// This is used to identify the index of this node as it appears in the collection.
        /// </summary>
        /// <param name="node">The node to test</param>
        /// <returns>The index of the node, or -1 if it is not in this collection</returns>
        public int IndexOf(CHtmlNode node)
        {
            System.Diagnostics.Debug.Assert(node != null);

            return m_nodeList.IndexOf(node);
        }
        /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// This is used to identify the index of this node as it appears in the collection.
        /// </summary>
        /// <param name="node">The node to test</param>
        /// <returns>The index of the node, or -1 if it is not in this collection</returns>
        public int IndexOf(CHtmlNode node)
        {
            System.Diagnostics.Debug.Assert(node != null);

            return(m_nodeList.IndexOf(node));
        }