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

📄 tagparser.cs

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

    public class TagParser
    {
        private static TagParserConfiguration config = TagParserConfiguration.LoadConfiguration();
        private TagDocument doc;
        private TagNodeCollection nodes;

        internal TagParser(string source, bool ignoreUnknowTags)
        {
            this.doc = TagDocument.Create(source, true);
            if (!ignoreUnknowTags)
            {
                this.nodes = this.doc.Nodes;
            }
            else
            {
                this.nodes = this.GetFilteredNodes(this.doc.Nodes);
            }
        }

        public static Imps.Utils.TagParser.TagParser Create(string source, bool ignoreUnknowTags)
        {
            return new Imps.Utils.TagParser.TagParser(source, ignoreUnknowTags);
        }

        private TagNodeCollection GetFilteredNodes(TagNodeCollection nodes)
        {
            TagNodeCollection nodes2 = new TagNodeCollection();
            foreach (TagNode node in nodes)
            {
                TagElement element = node as TagElement;
                if (element == null)
                {
                    nodes2.Add(node);
                    continue;
                }
                if (this.IsKnownTag(element.Name))
                {
                    TagNodeCollection nodes3 = element.Nodes.Clone();
                    element.Nodes.Clear();
                    element.Nodes.AddNodes(this.GetFilteredNodes(nodes3));
                    nodes2.Add(element);
                    continue;
                }
                nodes2.AddNodes(this.GetFilteredNodes(element.Nodes));
            }
            return nodes2;
        }

        private bool IsKnownTag(string tagName)
        {
            return config.Configurations.ContainsKey(tagName);
        }

        public string HTML
        {
            get
            {
                StringBuilder builder = new StringBuilder();
                foreach (TagNode node in this.Nodes)
                {
                    builder.Append(node.HTML);
                }
                return builder.ToString();
            }
        }

        public TagNodeCollection Nodes
        {
            get
            {
                return this.nodes;
            }
        }

        public string Text
        {
            get
            {
                StringBuilder builder = new StringBuilder();
                foreach (TagNode node in this.Nodes)
                {
                    builder.Append(node.Text);
                }
                return builder.ToString();
            }
        }
    }
}

⌨️ 快捷键说明

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