📄 rdlcinitobject.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace MSReport
{
public class RDLCInitObject : RDLCElement, IRDLCElement
{
public RDLCInitObject()
{
}
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));
}
}
}
foreach (XmlNode xmlnode in this.ActXNode.ChildNodes)
{
if (!this.NodeList.ContainsKey(GetName(xmlnode.Name)))
{
if (xmlnode.Name == "#text")
{
this.XMLString = "";
}
else
{
if (xmlnode.ParentNode != null)
{
XmlNodeList nlist = xmlnode.ParentNode.SelectNodes(SetXMLNamespace(xmlnode.Name), this.nsmgr);
if (nlist.Count == 1)
{
this.NodeList.Add(GetName(xmlnode.Name), GetRDLCInitObject(GetName(xmlnode.Name)));
}
else
{
this.NodeList.Add(GetName(xmlnode.Name), GetRDLCInitObject2(GetName(xmlnode.Name)));
}
}
else
{
this.NodeList.Add(GetName(xmlnode.Name), GetRDLCInitObject(GetName(xmlnode.Name)));
}
}
}
}
if (this.ActXNode.ChildNodes.Count == 0)
{
this.XMLString = "";
}
foreach (string xml in this.NodeList.Values)
{
this.XMLString += xml;
}
return GetRDLCInitObject();
}
public string GetRDLCInitObject(string ChildName)
{
string str = @"
ChildList = ObjectNode.SelectNodes(@" + this.cstr(SetXMLNamespace(ChildName)) + @",this.nsmgr);
foreach (XmlNode node in ChildList)
{
if (node.Name == " + this.cstr(ChildName) + @")
{
_" + GetName(ChildName) + @"=new " + GetName(ChildName) + @"();
_" + GetName(ChildName) + @".nsmgr = this.nsmgr;
_" + GetName(ChildName) + @".InitObject(node);
this.AddChildElement(_" + GetName(ChildName) + @");
}
}";
return str;
}
public string GetRDLCInitObject2(string ChildName)
{
string str = @"
ChildList = ObjectNode.SelectNodes(@" + this.cstr(SetXMLNamespace(ChildName)) + @",this.nsmgr);
foreach (XmlNode node in ChildList)
{
if (node.Name == " + this.cstr(ChildName) + @")
{
" + GetName(ChildName) + @" _" + GetName(ChildName) + @"=new " + GetName(ChildName) + @"();
_" + GetName(ChildName) + @".nsmgr = this.nsmgr;
_" + GetName(ChildName) + @".InitObject(node);
this.AddChildElement(_" + GetName(ChildName) + @");
}
}";
return str;
}
//if (_"+ GetName(ChildName) +@"Collection == null)
// {
// _" + GetName(ChildName) + @"Collection = new List<" + GetName(ChildName) + @">();
// }
// _" + GetName(ChildName) + @"Collection.Add(_" + GetName(ChildName) + @");
public string GetActNodeAttribute(string ChildName)
{
string str = @"
if (ObjectNode.Attributes[" + this.cstr(ChildName) + @"] != null)
{
_" + this.GetName(ChildName) + @" = ObjectNode.Attributes[" + this.cstr(ChildName) + @"].Value;
}";
return str;
}
public string GetRDLCInitObject()
{
return @" public override void InitObject(XmlNode ObjectNode)
{
XmlNodeList ChildList = null;
" + this.XMLString + @"
}";;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -