本文整理汇总了C#中XmlElementHelper.SetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElementHelper.SetAttribute方法的具体用法?C# XmlElementHelper.SetAttribute怎么用?C# XmlElementHelper.SetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlElementHelper
的用法示例。
在下文中一共展示了XmlElementHelper.SetAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SerializeCore
protected override void SerializeCore(XmlElement element, SaveContext context)
{
var helper = new XmlElementHelper(element);
helper.SetAttribute("guid", GUID);
helper.SetAttribute("text", Text);
helper.SetAttribute("x", X);
helper.SetAttribute("y", Y);
}
示例2: SerializeCore
protected override void SerializeCore(XmlElement nodeElement, SaveContext context)
{
base.SerializeCore(nodeElement, context);
XmlElement outEl = nodeElement.OwnerDocument.CreateElement(typeof(string).FullName);
var helper = new XmlElementHelper(outEl);
helper.SetAttribute("value", SerializeValue());
nodeElement.AppendChild(outEl);
}
示例3: TestDoubleAttributes
public void TestDoubleAttributes()
{
XmlElement element = xmlDocument.CreateElement("element");
// Test attribute writing.
XmlElementHelper writer = new XmlElementHelper(element);
writer.SetAttribute("ValidName", -12.34);
// Test reading of existing attribute.
XmlElementHelper reader = new XmlElementHelper(element);
Assert.AreEqual(-12.34, reader.ReadDouble("ValidName"));
// Test reading of non-existence attribute with default value.
Assert.AreEqual(56.78, reader.ReadDouble("InvalidName", 56.78));
// Test reading of non-existence attribute without default value.
Assert.Throws<InvalidOperationException>(() =>
{
reader.ReadDouble("InvalidName");
});
}
示例4: TestBooleanAttributes
public void TestBooleanAttributes()
{
XmlElement element = xmlDocument.CreateElement("element");
// Test attribute writing.
XmlElementHelper writer = new XmlElementHelper(element);
writer.SetAttribute("ValidName", true);
// Test reading of existing attribute.
XmlElementHelper reader = new XmlElementHelper(element);
Assert.AreEqual(true, reader.ReadBoolean("ValidName"));
// Test reading of non-existence attribute with default value.
Assert.AreEqual(true, reader.ReadBoolean("InvalidName", true));
Assert.AreEqual(false, reader.ReadBoolean("InvalidName", false));
// Test reading of non-existence attribute without default value.
Assert.Throws<InvalidOperationException>(() =>
{
reader.ReadBoolean("InvalidName");
});
}
示例5: SaveNode
protected override void SaveNode(XmlDocument xmlDoc, XmlElement nodeElement, SaveContext context)
{
base.SaveNode(xmlDoc, nodeElement, context);
var helper = new XmlElementHelper(nodeElement);
helper.SetAttribute("CodeText", code);
helper.SetAttribute("ShouldFocus", shouldFocus);
}
示例6: SerializeCore
protected override void SerializeCore(XmlElement element, SaveContext context)
{
base.SerializeCore(element, context);
var helper = new XmlElementHelper(element);
helper.SetAttribute("Script", this.Script);
}
示例7: SerializeCore
protected override void SerializeCore(XmlElement element)
{
XmlElementHelper helper = new XmlElementHelper(element);
helper.SetAttribute("NodeId", NodeId);
}
示例8: SerializeCore
protected override void SerializeCore(XmlElement element, SaveContext context)
{
var helper = new XmlElementHelper(element);
helper.SetAttribute("guid", GUID);
helper.SetAttribute("start", Start.Owner.GUID);
helper.SetAttribute("start_index", Start.Index);
helper.SetAttribute("end", End.Owner.GUID);
helper.SetAttribute("end_index", End.Index);
//helper.SetAttribute("portType", ((int) End.PortType));
}
示例9: SerializeCore
protected override void SerializeCore(XmlElement element, SaveContext context)
{
XmlElementHelper helper = new XmlElementHelper(element);
helper.SetAttribute(DummyModel.RadiusName, this.Radius);
helper.SetAttribute(DummyModel.IdName, this.Identifier);
}
示例10: SaveRecordedCommands
internal string SaveRecordedCommands()
{
var document = new XmlDocument();
XmlElement commandRoot = document.CreateElement("Commands");
document.AppendChild(commandRoot);
const string format = "Commands-{0:yyyyMMdd-hhmmss}.xml";
string xmlFileName = string.Format(format, DateTime.Now);
string xmlFilePath = Path.Combine(Path.GetTempPath(), xmlFileName);
// Create attributes that applied to the entire recording.
var helper = new XmlElementHelper(commandRoot);
helper.SetAttribute(EXIT_ATTRIB_NAME, ExitAfterPlayback);
helper.SetAttribute(PAUSE_ATTRIB_NAME, PauseAfterPlayback);
helper.SetAttribute(INTERVAL_ATTRIB_NAME, CommandInterval);
// Serialization in SaveContext.File may need file path. Add it
// temporarily and remove it after searilization.
NodeUtils.SetDocumentXmlPath(document, xmlFilePath);
foreach (DynamoModel.RecordableCommand command in recordedCommands)
commandRoot.AppendChild(command.Serialize(document));
NodeUtils.SetDocumentXmlPath(document, null);
// Save recorded commands into XML file and open it in viewer.
document.Save(xmlFilePath);
return xmlFilePath;
}
示例11: SaveRecordedCommands
internal string SaveRecordedCommands()
{
XmlDocument document = new XmlDocument();
XmlElement commandRoot = document.CreateElement("Commands");
document.AppendChild(commandRoot);
// Create attributes that applied to the entire recording.
XmlElementHelper helper = new XmlElementHelper(commandRoot);
helper.SetAttribute(ExitAttribName, ExitAfterPlayback);
helper.SetAttribute(PauseAttribName, PauseAfterPlayback);
helper.SetAttribute(IntervalAttribName, CommandInterval);
foreach (DynCmd.RecordableCommand command in recordedCommands)
commandRoot.AppendChild(command.Serialize(document));
string format = "Commands-{0:yyyyMMdd-hhmmss}.xml";
string xmlFileName = string.Format(format, DateTime.Now);
string xmlFilePath = Path.Combine(Path.GetTempPath(), xmlFileName);
// Save recorded commands into XML file and open it in viewer.
document.Save(xmlFilePath);
return xmlFilePath;
}
示例12: SerializeCore
protected override void SerializeCore(XmlElement element, SaveContext context)
{
base.SerializeCore(element, context); // Base implementation must be called.
var helper = new XmlElementHelper(element);
helper.SetAttribute("conversionMetric", SelectedMetricConversion.ToString());
helper.SetAttribute("conversionFrom", SelectedFromConversion.ToString());
helper.SetAttribute("conversionTo", SelectedToConversion.ToString());
}
示例13: SerializeCore
protected override void SerializeCore(XmlElement element, SaveContext context)
{
XmlElementHelper helper = new XmlElementHelper(element);
// Set the type attribute
helper.SetAttribute("type", this.GetType().ToString());
helper.SetAttribute("guid", this.GUID);
helper.SetAttribute("nickname", this.NickName);
helper.SetAttribute("x", this.X);
helper.SetAttribute("y", this.Y);
helper.SetAttribute("isVisible", this.IsVisible);
helper.SetAttribute("isUpstreamVisible", this.IsUpstreamVisible);
helper.SetAttribute("lacing", this.ArgumentLacing.ToString());
if (context == SaveContext.Undo)
{
// Fix: MAGN-159 (nodes are not editable after undo/redo).
helper.SetAttribute("interactionEnabled", this.interactionEnabled);
helper.SetAttribute("nodeState", this.state.ToString());
}
}
示例14: SerializeCore
public override void SerializeCore(XmlElement element, SaveContext context)
{
base.SerializeCore(element, context);
var helper = new XmlElementHelper(element);
helper.SetAttribute("name", Definition.MangledName);
}
示例15: SerializeCore
protected override void SerializeCore(XmlElement element, SaveContext context)
{
base.SerializeCore(element, context); //Base implementation must be called
if (context != SaveContext.Undo) return;
var helper = new XmlElementHelper(element);
helper.SetAttribute("functionId", Definition.FunctionId.ToString());
helper.SetAttribute("functionName", NickName);
helper.SetAttribute("functionDesc", Description);
XmlDocument xmlDoc = element.OwnerDocument;
foreach (string input in InPortData.Select(x => x.NickName))
{
XmlElement inputEl = xmlDoc.CreateElement("functionInput");
inputEl.SetAttribute("inputValue", input);
element.AppendChild(inputEl);
}
foreach (string input in OutPortData.Select(x => x.NickName))
{
XmlElement outputEl = xmlDoc.CreateElement("functionOutput");
outputEl.SetAttribute("outputValue", input);
element.AppendChild(outputEl);
}
}