本文整理汇总了C#中XmlHelper.AddElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlHelper.AddElement方法的具体用法?C# XmlHelper.AddElement怎么用?C# XmlHelper.AddElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlHelper
的用法示例。
在下文中一共展示了XmlHelper.AddElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generate
public XmlElement Generate(XmlElement serviceDefinition)
{
ServiceEntity service = ServiceEntity.Parse(serviceDefinition);
XmlHelper h = new XmlHelper("<Request/>");
XmlElement reqElement = h.GetElement(".");
XmlElement recElement = h.AddElement(".", service.RequestRecordElement);
XmlHelper recHelper = new XmlHelper(recElement);
XmlElement fieldElement = recHelper.GetElement(".");
if (!string.IsNullOrWhiteSpace(service.FieldList.Source))
fieldElement = recHelper.AddElement(".", service.FieldList.Source);
XmlHelper fieldHelper = new XmlHelper(fieldElement);
List<Field> _requires = new List<Field>();
List<Field> _notRequries = new List<Field>();
foreach (Field field in service.FieldList.Fields)
{
if (field.SourceType != SourceType.Request) continue;
if (field.AutoNumber) continue;
if (field.InputType == IOType.Attribute)
fieldElement.SetAttribute(field.Source, string.Empty);
else if (field.Required)
_requires.Add(field);
else
_notRequries.Add(field);
}
if (_requires.Count > 0)
{
XmlNode node = reqElement.OwnerDocument.CreateComment("以下為必要欄位");
fieldElement.AppendChild(node);
foreach (Field field in _requires)
{
string value = string.Empty;
if (field.InputType == IOType.Xml)
value = "xml";
fieldHelper.AddElement(".", field.Source, value);
}
}
if (_notRequries.Count > 0)
{
XmlNode node = reqElement.OwnerDocument.CreateComment("以下為非必要欄位");
fieldElement.AppendChild(node);
foreach (Field field in _notRequries)
{
string value = string.Empty;
if (field.InputType == IOType.Xml)
value = "xml";
fieldHelper.AddElement(".", field.Source, value);
}
}
return reqElement;
}
示例2: AddContract
internal ContractHandler AddContract(string ContractName, ExtendType extend)
{
XmlHelper req = new XmlHelper("<Request/>");
req.AddElement(".", "ContractName", ContractName);
req.AddElement(".", "Definition");
XmlElement authElement = req.AddElement("Definition", "Authentication");
if (extend == ExtendType.open)
{
XmlElement e = req.AddElement("Definition/Authentication", "Public");
e.SetAttribute("Enabled", "true");
}
else
{
if (extend != ExtendType.none && extend != ExtendType.open)
authElement.SetAttribute("Extends", extend.ToString());
}
Parent.SendRequest("UDSManagerService.CreateContract", new Envelope(req));
ContractHandler contract = ContractHandler.CreateNew(ContractName, extend);
JoinProject(contract);
return contract;
}
示例3: ListProjects
internal List<string> ListProjects()
{
if (_projects != null)
return _projects;
XmlHelper req = new XmlHelper("<Request/>");
req.AddElement(".", "Condition");
req.AddElement("Condition", "Name", PROJECT_LIST_PS_NAME);
Envelope evn = MainForm.LoginArgs.GreeningConnection.SendRequest("GetMySpace", new Envelope(req));
XmlHelper rsp = new XmlHelper(evn.Body);
_projects = new List<string>();
if (rsp.GetElement("Space") == null)
{
req = new XmlHelper("<Request/>");
req.AddElement(".", "Space");
req.AddElement("Space", "Name", PROJECT_LIST_PS_NAME);
XmlElement content = req.AddElement("Space", "Content");
XmlCDataSection section = content.OwnerDocument.CreateCDataSection("<ProjectList/>");
content.AppendChild(section);
MainForm.LoginArgs.GreeningConnection.SendRequest("CreateSpace", new Envelope(req));
}
else
{
string content = rsp.GetText("Space/Content");
XmlHelper h = new XmlHelper(content);
foreach (XmlElement projectElement in h.GetElements("Project"))
_projects.Add(projectElement.GetAttribute("Name"));
}
return _projects;
}
示例4: Start
public void Start()
{
int count = _recElements.Count;
for (int batchNumber = 0; batchNumber < this.BatchCount; batchNumber++)
{
XmlHelper h = new XmlHelper(RequestContentElement);
int start = batchNumber * this.Size;
int end = start + this.Size;
if (end > count)
end = count;
for (int i = start; i < end; i++)
{
XmlElement rec = _recElements[i];
h.AddElement(".", rec);
}
Envelope env = new Envelope(h);
XmlHelper p = new XmlHelper("<Parameter/>");
p.AddElement(".", "BatchID", _batchID);
p.AddElement(".", "BatchNumber", batchNumber.ToString());
env.Headers.Add(p);
BackgroundWorker w = new BackgroundWorker();
w.DoWork += new DoWorkEventHandler(w_DoWork);
w.RunWorkerCompleted += new RunWorkerCompletedEventHandler(w_RunWorkerCompleted);
w.RunWorkerAsync(env);
}
}
示例5: btnSave_Click
private void btnSave_Click(object sender, EventArgs e)
{
if (txtModule.Text == _moduleURL && txtGreening.Text == _greeningURL)
{
this.Close();
return;
}
DialogResult dr = MessageBox.Show("設定已變更, 儲存後必須重新啟動程式以套用新設定。\n是否儲存?", "問題", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (dr == System.Windows.Forms.DialogResult.Yes)
{
string path = Path.Combine(Environment.CurrentDirectory, "Setup.config");
//if (File.Exists(path))
// File.Delete(path);
XmlHelper h = new XmlHelper("<Setup/>");
h.AddElement(".", "GreeningAccessPoint", txtGreening.Text);
h.AddElement(".", "ModuleAccessPoint", txtModule.Text);
h.GetElement(".").OwnerDocument.Save(path);
if (SetupChanged != null)
SetupChanged.Invoke(this, e);
else
MessageBox.Show("儲存完畢", "完成", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
this.Close();
}
示例6: button1_Click
private void button1_Click(object sender, EventArgs e)
{
try
{
MainForm.DefaultDevSite.User = txtUser.Text;
MainForm.DefaultDevSite.Password = txtPassword.Text;
MainForm.DefaultDevSite.AccessPoint = txtAP.Text;
MainForm.DefaultDevSite.ContractName = cboContract.Text;
XmlHelper apXml = new XmlHelper("<AppContent/>");
apXml.AddElement(".", "AccessPoint", txtAP.Text);
apXml.AddElement(".", "ContractName", cboContract.Text);
apXml.AddElement(".", "User", txtUser.Text);
apXml.AddElement(".", "Password", txtPassword.Text);
MainForm.Storage.SetPropertyXml("DevLoginAP", txtAP.Text, apXml.GetElement("."));
MainForm.Storage.SetProperty("DevLastLoginAP", txtAP.Text);
MainForm.Storage.SetProperty("DevLastLoginContract", cboContract.Text);
MainForm.Storage.SetProperty("DevLastLoginName", txtUser.Text);
MainForm.Storage.SetProperty("DevLastLoginPassword", txtPassword.Text);
MainForm.Storage.SetProperty("DevAutoLogin", chkAutoLogin.Checked.ToString().ToLower());
MainForm.LoginArgs.StaticPreference = apXml.GetElement("."); ;
this.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例7: AddService
public static void AddService(string contractName, string packageName, ServiceEntity service)
{
XmlHelper req = new XmlHelper();
req.AddElement(".", "ContractName", contractName);
req.AddElement(".", "PackageName", packageName);
req.AddElement(".", service.GetServiceXml());
MainForm.CurrentProject.SendRequest("UDSManagerService.CreateService", new Envelope(req));
}
示例8: SetDefinition
public static void SetDefinition(string contractName, string packageName, string serviceName, XmlElement definition)
{
XmlHelper req = new XmlHelper();
req.AddElement(".", "ContractName", contractName);
req.AddElement(".", "PackageName", packageName);
req.AddElement(".", "ServiceName", serviceName);
req.AddElement(".", definition);
MainForm.CurrentProject.SendRequest("UDSManagerService.SetServiceDefinition", new Envelope(req));
}
示例9: Rename
public static void Rename(string contractName, string packageName, string serviceName, string newName)
{
XmlHelper req = new XmlHelper();
req.AddElement(".", "ContractName", contractName);
req.AddElement(".", "PackageName", packageName);
req.AddElement(".", "ServiceName", serviceName);
req.AddElement(".", "NewServiceName", newName);
MainForm.CurrentProject.SendRequest("UDSManagerService.RenameService", new Envelope(req));
}
示例10: btnOK_Click
private void btnOK_Click(object sender, EventArgs e)
{
XmlHelper h = new XmlHelper();
h.AddElement(".", "UsePassport", rbPassport.Checked.ToString());
h.AddElement(".", "User", txtUser.Text);
h.AddElement(".", "Password", txtPwd.Text);
h.AddElement(".", "Auth", txtProvider.Text);
MainForm.Storage.SetPropertyXml("ServiceTestTemp", _contractUniqName, h.GetElement("."));
this.Hide();
}
示例11: GetRawService
public static XmlElement GetRawService(string contractName, string packageName, string serviceName)
{
XmlHelper req = new XmlHelper();
req.AddElement(".", "ContractName", contractName);
req.AddElement(".", "PackageName", packageName);
req.AddElement(".", "ServiceName", serviceName);
Envelope env = MainForm.CurrentProject.SendRequest("UDSManagerService.GetServiceDefinition", new Envelope(req));
XmlHelper rsp = new XmlHelper(env.Body);
return rsp.GetElement(".");
}
示例12: AddPackage
internal PackageHandler AddPackage(string packageName)
{
XmlHelper req = new XmlHelper("<Request/>");
req.AddElement(".", "ContractName", this.Name);
req.AddElement(".", "PackageName", packageName);
MainForm.CurrentProject.SendRequest("UDSManagerService.CreatePackage", new Envelope(req));
PackageHandler ph = PackageHandler.CreateNew(this, packageName);
_packages.Add(ph);
return ph;
}
示例13: GetSample
public XmlElement GetSample()
{
XmlHelper h = new XmlHelper("<Converter />");
h.SetAttribute(".", "Name", this.Name);
h.SetAttribute(".", "Type", this.Type);
h.AddElement(".", "InputFormat", DefaultInputFormat);
h.AddElement(".", "OutputFormat", DefaultOutputFormat);
return h.GetElement(".");
}
示例14: Rename
internal void Rename(string newName)
{
XmlHelper req = new XmlHelper("<Request/>");
req.AddElement(".", "ContractName", this.Contract.Name);
req.AddElement(".", "PackageName", this.Name);
req.AddElement(".", "NewPackageName", newName);
MainForm.CurrentProject.SendRequest("UDSManagerService.RenamePackage", new Envelope(req));
this.Name = newName;
if (Renamed != null)
Renamed.Invoke(this, EventArgs.Empty);
}
示例15: GetSample
public XmlElement GetSample()
{
XmlHelper h = new XmlHelper("<Converter />");
h.SetAttribute(".", "Name", this.Name);
h.SetAttribute(".", "Type", this.Type);
XmlElement e = h.AddElement(".", "Item", "return_value");
e.SetAttribute("If", "get_value");
h.AddElement(".", "Default", "no_match_default_value");
return h.GetElement(".");
}