本文整理汇总了C#中System.Xml.XmlNode.GetAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XmlNode.GetAttribute方法的具体用法?C# XmlNode.GetAttribute怎么用?C# XmlNode.GetAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlNode
的用法示例。
在下文中一共展示了XmlNode.GetAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FieldDefinition
public FieldDefinition(GeneratorBase generator, XmlNode field)
{
Type = field.GetAttribute("type");
Name = field.GetAttribute("name");
Description = field.InnerText;
ArrayLength = 0;
string alternativeName;
if (generator.ReservedWords.TryGetValue(Name, out alternativeName))
Name = alternativeName;
Match match = _arrayRegEx.Match(Type);
if (match.Success)
{
// It's an array, modify Type and remember length of array
ArrayLength = int.Parse(match.Groups["length"].Value);
Type = Type.Replace(match.Value, "");
}
Tuple<string, int> csharpType;
if (generator.TypeMap.TryGetValue(Type, out csharpType))
{
Type = csharpType.Item1;
TypeSize = csharpType.Item2;
}
if (ArrayLength > 0)
{
Type = generator.GetArrayDefinitionForType(Type, ArrayLength, TypeSize);
}
}
示例2: TestFinished
/// <summary>
/// Called when a test has finished
/// </summary>
/// <param name="result">The result of the test</param>
public void TestFinished(XmlNode result)
{
string name = result.GetAttribute("fullname");
double duration = result.GetAttribute("duration", 0.0);
string testId = result.GetAttribute("id");
switch (result.GetAttribute("result"))
{
case "Passed":
TC_TestFinished(name, duration, testId);
break;
case "Inconclusive":
TC_TestIgnored(name, "Inconclusive", testId);
break;
case "Skipped":
XmlNode reason = result.SelectSingleNode("reason/message");
TC_TestIgnored(name, reason == null ? "" : reason.InnerText, testId);
break;
case "Failed":
XmlNode message = result.SelectSingleNode("failure/message");
XmlNode stackTrace = result.SelectSingleNode("failure/stack-trace");
TC_TestFailed(name, message == null ? "" : message.InnerText, stackTrace == null ? "" : stackTrace.InnerText, testId);
TC_TestFinished(name, duration, testId);
break;
}
}
示例3: TestStarted
public void TestStarted(XmlNode node)
{
string name = node.GetAttribute("fullname");
string testId = node.GetAttribute("id");
_outWriter.WriteLine("##teamcity[testStarted name='{0}' captureStandardOutput='true' flowId='{1}']", Escape(name), Escape(testId));
}
示例4: Summarize
private static void Summarize(ResultSummary s, XmlNode node)
{
string type = node.GetAttribute("type");
string status = node.GetAttribute("result");
string label = node.GetAttribute("label");
switch (node.Name)
{
case "test-case":
s.TestCount++;
switch (status)
{
case "Passed":
s.PassCount++;
break;
case "Failed":
if (label == null)
s.FailureCount++;
else if (label == "Invalid")
s.InvalidCount++;
else
s.ErrorCount++;
break;
case "Inconclusive":
s.InconclusiveCount++;
break;
case "Skipped":
if (label == "Ignored")
s.IgnoreCount++;
else if (label == "Explicit")
s.ExplicitCount++;
else
s.SkipCount++;
break;
default:
s.SkipCount++;
break;
}
break;
case "test-suite":
if (type == "Assembly" && status == "Failed" && label == "Invalid")
s.InvalidAssemblies++;
if (type == "Assembly" && status == "Failed" && label == "Error")
{
s.InvalidAssemblies++;
s.UnexpectedError = true;
}
Summarize(s, node.ChildNodes);
break;
case "test-run":
Summarize(s, node.ChildNodes);
break;
}
}
示例5: Summarize
private void Summarize(XmlNode node)
{
switch (node.Name)
{
case "test-case":
resultCount++;
string outcome = node.GetAttribute("result");
string label = node.GetAttribute("label");
if (label != null)
outcome = label;
switch (outcome)
{
case "Passed":
successCount++;
testsRun++;
break;
case "Failed":
failureCount++;
testsRun++;
break;
case "Error":
case "Cancelled":
errorCount++;
testsRun++;
break;
case "Inconclusive":
inconclusiveCount++;
testsRun++;
break;
case "NotRunnable": // TODO: Check if this can still occur
case "Invalid":
notRunnable++;
break;
case "Ignored":
ignoreCount++;
break;
case "Skipped":
default:
skipCount++;
break;
}
break;
//case "test-suite":
//case "test-fixture":
//case "method-group":
default:
foreach (XmlNode childResult in node.ChildNodes)
Summarize(childResult);
break;
}
}
示例6: NUnit2ResultSummary
public NUnit2ResultSummary(XmlNode result)
{
if (result.Name != "test-run")
throw new InvalidOperationException("Expected <test-run> as top-level element but was <" + result.Name + ">");
name = result.GetAttribute("name");
duration = result.GetAttribute("duration", 0.0);
startTime = result.GetAttribute("start-time", DateTime.MinValue);
endTime = result.GetAttribute("end-time", DateTime.MaxValue);
Summarize(result);
}
示例7: ResultReporter
public ResultReporter(XmlNode result, ConsoleOptions options)
{
this.result = result;
this.testRunResult = result.GetAttribute("result");
this.options = options;
this.summary = new ResultSummary(result);
}
示例8: RenderControl
public List<WebControl> RenderControl(XmlNode xmlControl)
{
base.Initialize(xmlControl);
XmlNode valuesNode = _PropertyMapper.GetValuesNode();
var firstPass = true;
var groupName = string.Empty;
var name = string.Empty;
foreach (XmlNode xmlValueNode in valuesNode.ChildNodes)
{
if (firstPass)
{
firstPass = false;
groupName = "Group" + _PropertyMapper.GetName();
name = _PropertyMapper.GetID();
}
ASPxRadioButton aspxRadioButton = new ASPxRadioButton
{
ID = "rad" + xmlValueNode.GetAttribute("CCLAVE"),
Text = xmlValueNode.GetAttribute("CTEXTO"),
Value = xmlValueNode.GetAttribute("CCLAVE"),
ClientInstanceName = name,
Checked = (_PropertyMapper.GetDefault() == xmlValueNode.GetAttribute("CCLAVE")) ? true : false,
GroupName = groupName
};
try
{
if (xmlControl.GetAttribute("CCONTROLASOC") != null)
{
aspxRadioButton.ClientSideEvents.CheckedChanged = "function(s, e) { if(s.GetChecked()) {" + xmlControl.GetAttribute("CCONTROLASOC") + ".PerformCallback('" + xmlValueNode.GetAttribute("CCLAVE") + "');} }";
aspxRadioButton.ClientSideEvents.Init = "function(s, e) { if(s.GetChecked()) {" + xmlControl.GetAttribute("CCONTROLASOC") + ".PerformCallback('" + xmlValueNode.GetAttribute("CCLAVE") + "');} }";
}
}
catch (Exception)
{
}
_Controls.Add(aspxRadioButton);
}
return _Controls;
}
示例9: ParseAxis
private static Axis ParseAxis(XmlNode axisNode)
{
var axis = new Axis();
axis.Name = ParseJoystickAxis(axisNode);
axis.Action = ParseJoystickAxisAction(axisNode.InnerText);
axis.IsInverted = Boolean.Parse(axisNode.GetAttribute("Inverted"));
return axis;
}
示例10: Read
public Instance Read(XmlNode node, Type pluginType)
{
Type elementType = pluginType.GetElementType();
char delimiter = node.GetAttribute("Delimiter", ",").ToCharArray()[0];
string valueString = node.GetAttribute("Values", string.Empty);
string[] rawValues = valueString.Split(new[] {delimiter}, StringSplitOptions.RemoveEmptyEntries);
Array array = Array.CreateInstance(elementType, rawValues.Length);
for (int i = 0; i < rawValues.Length; i++)
{
object convertedType = Convert.ChangeType(rawValues[i].Trim(), elementType);
array.SetValue(convertedType, i);
}
return new SerializedInstance(array);
}
示例11: RenderControl
public List<WebControl> RenderControl(XmlNode xmlControl)
{
base.Initialize(xmlControl);
ASPxComboBox aspxListBox = new ASPxComboBox
{
ID = _PropertyMapper.GetID(),
ClientInstanceName = _PropertyMapper.GetID()
};
if (string.IsNullOrEmpty(_PropertyMapper.GetDefault()))
aspxListBox.SelectedIndex = 0;
aspxListBox.Callback += new DevExpress.Web.ASPxClasses.CallbackEventHandlerBase(aspxListBox_Callback);
XmlNode valuesNode = _PropertyMapper.GetValuesNode();
// Carga los datos de la lista
foreach (XmlNode xmlValueNode in valuesNode.ChildNodes)
{
ListEditItem listEditItem = new ListEditItem();
listEditItem.Value = xmlValueNode.GetAttribute("CCLAVE");
listEditItem.Text = xmlValueNode.GetAttribute("CTEXTO");
listEditItem.Selected = (_PropertyMapper.GetDefault() == xmlValueNode.GetAttribute("CCLAVE")) ? true : false;
aspxListBox.Items.Add(listEditItem);
}
try
{
if (xmlControl.GetAttribute("CCONTROLASOC") != null)
{
aspxListBox.ClientSideEvents.ValueChanged = "function(s, e) {" + xmlControl.GetAttribute("CCONTROLASOC") + ".PerformCallback(" + _PropertyMapper.GetID() + ".GetValue());}";
aspxListBox.ClientSideEvents.Init = "function(s, e) {" + xmlControl.GetAttribute("CCONTROLASOC") + ".PerformCallback(" + _PropertyMapper.GetID() + ".GetValue());}";
}
}
catch (Exception)
{
}
_Controls.Add(aspxListBox);
return _Controls;
}
示例12: parseNoteNode
/// <summary>
/// 解析 XmlNode 为 model
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
private static ToDoModel parseNoteNode(XmlNode node)
{
return new ToDoModel()
{
Deadline = DateTime.Parse(node.SelectSingleNode("deadline").GetInnerText()),
Content = node.SelectSingleNode("content").GetInnerText(),
IsDo = node.GetAttribute("isdo", "0") == "1"
};
}
示例13: ParseJoystickSetup
private static JoystickSetup ParseJoystickSetup(XmlNode joystickSetupNode)
{
var setup = new JoystickSetup();
setup.Name = joystickSetupNode.GetAttribute("Name");
XmlNodeList deviceNodes = joystickSetupNode.SelectNodes("JoystickDevice");
foreach (XmlNode deviceNode in deviceNodes)
setup.Devices.Add(ParseDevice(deviceNode));
return setup;
}
示例14: ParseDevice
private static JoystickDevice ParseDevice(XmlNode deviceNode)
{
var device = new JoystickDevice();
device.Name = deviceNode.GetAttribute("Name");
XmlNodeList axisNodes = deviceNode.SelectNodes("Axis");
foreach (XmlNode axisNode in axisNodes)
{
if (!String.IsNullOrEmpty(axisNode.ToString()))
device.Axes.Add(ParseAxis(axisNode));
}
return device;
}
示例15: parseNoteNode
private static NoteModel parseNoteNode(XmlNode noteNode)
{
return new NoteModel()
{
Keywords = noteNode.SelectSingleNode("keyword").GetInnerText(),
Title = noteNode.SelectSingleNode("title").GetInnerText(),
Content = noteNode.SelectSingleNode("content").GetInnerText(),
IsRead = noteNode.GetAttribute("isread", 0) == "1",
Type = int.Parse(noteNode.SelectSingleNode("type").GetInnerText()),
CreateTime =DateTime.Parse(noteNode.SelectSingleNode("createtime").GetInnerText())
};
}