📄 rdlcattribute.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace MSReport
{
public class RDLCAttribute : RDLCElement, IRDLCElement
{
public RDLCAttribute()
{
}
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.Replace(":", "_");
if (!this.NodeList.ContainsKey(name))
{
this.NodeList.Add(name, CreateAttribute2(name));
}
}
}
if (this.ActXNode.ChildNodes.Count == 0)
{
if (!this.NodeList.ContainsKey("Text"))
{
this.NodeList.Add("Text", CreateAttribute2("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", CreateAttribute2("Text"));
}
}
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), CreateAttribute(GetName(xmlnode.Name)));
}
else
{
this.NodeList.Add(GetName(xmlnode.Name), CreateAttribute3(GetName(xmlnode.Name)));
}
}
else
{
this.NodeList.Add(GetName(xmlnode.Name), CreateAttribute(GetName(xmlnode.Name)));
}
}
}
}
foreach (string xml in this.NodeList.Values)
{
this.XMLString += xml;
}
return this.XMLString;
}
/// <summary>
/// 生成属性
/// </summary>
/// <param name="AttName"></param>
/// <returns></returns>
public string CreateAttribute(string AttName)
{
string appatt = @"
public " + AttName.Replace(":", "_") + @" " + AttName.Replace(":", "_") + @"
{
get
{
return _" + AttName.Replace(":", "_") + @";
}
set
{
_" + AttName.Replace(":", "_") + @" = value;
}
}
private " + AttName.Replace(":", "_") + @" _" + AttName.Replace(":", "_") + @" = null;";
return appatt;
}
/// <summary>
/// 生成属性
/// </summary>
/// <param name="AttName"></param>
/// <returns></returns>
public string CreateAttribute2(string AttName)
{
string appatt = @"
public string " + AttName + @"
{
get
{
return _" + AttName + @";
}
set
{
_" + AttName + @" = value;
}
}
private string _" + AttName + @" = " + this.cstr("") + ";";
return appatt;
}
/// <summary>
/// 生成属性
/// </summary>
/// <param name="AttName"></param>
/// <returns></returns>
public string CreateAttribute3(string AttName)
{
string appatt = @"
public List<" + AttName.Replace(":", "_") + @"> " + AttName.Replace(":", "_") + @"Collection
{
get
{
return _" + AttName.Replace(":", "_") + @"Collection;
}
set
{
_" + AttName.Replace(":", "_") + @"Collection = value;
}
}
private List<" + AttName.Replace(":", "_") + @"> _" + AttName.Replace(":", "_") + @"Collection = null;";
return appatt;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -