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

📄 rdlcwritechildelement.cs

📁 微软报表解析器语言生成器。选择微软的报表之后可以把每个节点生成一个实体类
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace MSReport
{
    public class RDLCWriteChildElement : RDLCElement, IRDLCElement
    {
        public RDLCWriteChildElement()
        {

        }
        public override string Create(XmlNode xnode)
        {
            this.ActXNode = xnode;
            this.XMLString = @"";
            if (this.ActXNode.Attributes != null)
            {
                for (int i = 0; i < this.ActXNode.Attributes.Count; i++)
                {
                    string name = this.ActXNode.Attributes[i].Name;
                    if (!this.NodeList.ContainsKey(name))
                    {
                        this.NodeList.Add(name, GetActNodeAttribute(name));
                    }
                }
            }
            if (this.ActXNode.ChildNodes.Count == 0)
            {
                if (!this.NodeList.ContainsKey("Text"))
                {
                    this.NodeList.Add("Text", @"xmlWriter.WriteString(_Text);");
                }
            }

            foreach (XmlNode xmlnode in this.ActXNode.ChildNodes)
            {
                if (!this.NodeList.ContainsKey(GetName(xmlnode.Name)))
                {
                    if (xmlnode.Name == "#text")
                    {
                        if (!this.NodeList.ContainsKey("Text"))
                        {
                            this.NodeList.Add("Text", @"xmlWriter.WriteString(_Text);");
                        }
                    }
                }
            }
            foreach (string xml in this.NodeList.Values)
            {
                this.XMLString += xml;
            }
            return GetRDLCWriteChildElement();
        }

        public string GetActNodeAttribute(string ChildName)
        {
            string str = "";
            if (this.ActXNode.ChildNodes.Count > 0)
            {
                if (this.ActXNode.ChildNodes[0].Name == "#text")
                {
                    str = @"  xmlWriter.WriteString(_Text);";
                }
                else
                {
                    str = @" 
 
                   xmlWriter.WriteAttributeString(" + this.cstr(ChildName) + @", " + this.GetName(ChildName) + @");";
                }
            }
            else
            {
                str = @"  xmlWriter.WriteString(_Text);";
            }
            return str;
        }

 
        public string GetRDLCWriteChildElement()
        {
            return @" public override void WriteChildElement(System.Xml.XmlTextWriter xmlWriter)
                {
                     xmlWriter.WriteStartElement(this.TagName);

                    " + this.XMLString + @"
                }"; ;
        }
    }
}

⌨️ 快捷键说明

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