⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tagnode.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Utils.TagParser
{
    using System;
    using System.ComponentModel;

    public abstract class TagNode
    {
        protected TagElement mParent = null;

        protected TagNode()
        {
        }

        public TagElement GetAncestor(string tagName)
        {
            for (TagElement parent = this.Parent; parent != null; parent = parent.Parent)
            {
                if (parent.Name.ToLower() == tagName.ToLower())
                {
                    return parent;
                }
            }
            return null;
        }

        [Category("Relationships")]
        public TagNode GetCommonAncestor(TagNode node)
        {
            for (TagNode parent = this; parent != null; parent = parent.Parent)
            {
                for (TagNode node3 = node; node3 != null; node3 = node3.Parent)
                {
                    if (parent == node3)
                    {
                        return parent;
                    }
                }
            }
            return null;
        }

        [Category("Relationships")]
        public bool IsAncestorOf(TagNode node)
        {
            return node.IsDescendentOf(this);
        }

        [Category("Relationships")]
        public bool IsDescendentOf(TagNode node)
        {
            for (TagNode mParent = this.mParent; mParent != null; mParent = mParent.Parent)
            {
                if (mParent == node)
                {
                    return true;
                }
            }
            return false;
        }

        [Category("General"), Description("This is true if this is an element node")]
        public bool IsElement()
        {
            return (this is TagElement);
        }

        [Category("General"), Description("This is true if this is a text node")]
        public bool IsText()
        {
            return (this is TextNode);
        }

        [Category("General")]
        public void Remove()
        {
            if (this.mParent != null)
            {
                this.mParent.Nodes.RemoveAt(this.Index);
            }
        }

        internal void SetParent(TagElement parentNode)
        {
            this.mParent = parentNode;
        }

        public abstract override string ToString();

        [Category("Navigation"), Description("The first child of this node")]
        public TagNode FirstChild
        {
            get
            {
                if (!(this is TagElement))
                {
                    return null;
                }
                if (((TagElement) this).Nodes.Count == 0)
                {
                    return null;
                }
                return ((TagElement) this).Nodes[0];
            }
        }

        public bool HasChild
        {
            get
            {
                if (this is TagElement)
                {
                    TagElement element = (TagElement) this;
                    if ((element.Nodes.Count == 1) && (element.FirstChild is TextNode))
                    {
                        return false;
                    }
                    return (((TagElement) this).Nodes.Count > 0);
                }
                if (this is TextNode)
                {
                    return false;
                }
                return false;
            }
        }

        [Category("Output"), Description("The HTML that represents this node and all the children")]
        public abstract string HTML { get; }

        [Description("The zero-based index of this node in the parent's nodes collection"), Category("Navigation")]
        public int Index
        {
            get
            {
                if (this.mParent == null)
                {
                    return -1;
                }
                return this.mParent.Nodes.IndexOf(this);
            }
        }

        [Description("Is this node a child of another?"), Category("Navigation")]
        public bool IsChild
        {
            get
            {
                return (this.mParent != null);
            }
        }

        [Description("Does this node have any children?"), Category("Navigation")]
        public bool IsParent
        {
            get
            {
                if (this is TagElement)
                {
                    return (((TagElement) this).Nodes.Count > 0);
                }
                return false;
            }
        }

        [Description("Is this node a root node?"), Category("Navigation")]
        public bool IsRoot
        {
            get
            {
                return (this.mParent == null);
            }
        }

        [Description("The last child of this node"), Category("Navigation")]
        public TagNode LastChild
        {
            get
            {
                if (!(this is TagElement))
                {
                    return null;
                }
                if (((TagElement) this).Nodes.Count == 0)
                {
                    return null;
                }
                return ((TagElement) this).Nodes[((TagElement) this).Nodes.Count - 1];
            }
        }

        [Category("Navigation"), Description("The next sibling node")]
        public TagNode Next
        {
            get
            {
                if ((this.Index != -1) && (this.Parent.Nodes.Count > (this.Index + 1)))
                {
                    return this.Parent.Nodes[this.Index + 1];
                }
                return null;
            }
        }

        [Description("The parent node of this one"), Category("Navigation")]
        public TagElement Parent
        {
            get
            {
                return this.mParent;
            }
        }

        [Description("The previous sibling node"), Category("Navigation")]
        public TagNode Previous
        {
            get
            {
                if ((this.Index != -1) && (this.Index > 0))
                {
                    return this.Parent.Nodes[this.Index - 1];
                }
                return null;
            }
        }

        [Description("The Text that represents this node and all the children"), Category("Output")]
        public abstract string Text { get; }

        [Category("Output"), Description("The XHTML that represents this node and all the children")]
        public abstract string XHTML { get; }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -