📄 frametranswhere.cs
字号:
namespace FrameCountry
{
using System;
using System.Reflection;
using System.Xml;
public class FrameTransWhere
{
private string ClassAlias;
private FrameCity frameCity;
private XmlDocument parentXmlDoc;
private XmlNode WhereXmlNode;
public FrameTransWhere()
{
this.ClassAlias = "TW";
this.frameCity = new FrameCity();
this.parentXmlDoc = new XmlDocument();
}
public FrameTransWhere(string NodeInnerXML)
{
this.ClassAlias = "TW";
this.frameCity = new FrameCity();
this.parentXmlDoc = new XmlDocument();
this.parentXmlDoc.LoadXml("<?xml version='1.0' encoding='gb2312'?><root>" + NodeInnerXML + "</root>");
this.WhereXmlNode = this.parentXmlDoc.ChildNodes[1];
}
public bool GetName(int index, ref string Name, ref string Operater, ref string ErrorInfo)
{
string functionAlias = "04";
try
{
if ((index < 0) || (index > this.WhereXmlNode.ChildNodes.Count))
{
throw new Exception("索引越界!");
}
Name = this.WhereXmlNode.ChildNodes[index].Name;
int num = index + 1;
Operater = this.parentXmlDoc.SelectSingleNode("/root/*[" + num.ToString() + "]").Attributes["Operator"].Value;
}
catch (Exception exception)
{
ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, exception.Message);
return false;
}
return true;
}
public bool GetWhereXmlNode(ref string NodeInnerXML, ref string ErrorInfo)
{
string functionAlias = "03";
try
{
NodeInnerXML = this.WhereXmlNode.InnerXml;
}
catch (Exception exception)
{
ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, exception.Message);
}
return true;
}
public bool SetWhereXmlNode(string NodeInnerXML, ref string ErrorInfo)
{
string functionAlias = "02";
try
{
this.parentXmlDoc.LoadXml("<?xml version='1.0' encoding='gb2312'?><root>" + NodeInnerXML + "</root>");
this.WhereXmlNode = this.parentXmlDoc.ChildNodes[1];
}
catch (Exception exception)
{
ErrorInfo = this.frameCity.DealErrorInfo(this.ClassAlias, functionAlias, exception.Message);
}
return true;
}
public int Count
{
get
{
try
{
return this.WhereXmlNode.ChildNodes.Count;
}
catch
{
return 0;
}
}
}
public string this[string index, string Operator]
{
get
{
try
{
return this.WhereXmlNode.SelectNodes("./" + index + "[@Operator=\"" + Operator + "\"]")[0].InnerText;
}
catch
{
return null;
}
}
set
{
try
{
this.WhereXmlNode.SelectNodes("./" + index + "[@Operator=\"" + Operator + "\"]")[0].InnerText = value;
}
catch
{
XmlElement newChild = this.parentXmlDoc.CreateElement(index);
newChild.InnerText = value;
XmlAttribute node = this.parentXmlDoc.CreateAttribute("Operator");
node.Value = Operator;
newChild.Attributes.Append(node);
this.WhereXmlNode.AppendChild(newChild);
}
}
}
public string this[string index]
{
get
{
try
{
return this.WhereXmlNode.SelectNodes("./" + index)[0].InnerText;
}
catch
{
return null;
}
}
set
{
try
{
this.WhereXmlNode.SelectNodes("./" + index)[0].InnerText = value;
}
catch
{
XmlElement newChild = this.parentXmlDoc.CreateElement(index);
newChild.InnerText = value;
this.WhereXmlNode.AppendChild(newChild);
XmlAttribute node = this.parentXmlDoc.CreateAttribute("Operator");
node.Value = "";
this.WhereXmlNode.SelectNodes("./" + index)[0].Attributes.Append(node);
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -