当前位置: 首页>>代码示例>>C#>>正文


C# XmlNode.GetAttribute方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:Romout,项目名称:MavLinkGenerator,代码行数:31,代码来源:FieldDefinition.cs

示例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;
            }
        }
开发者ID:JohanLarsson,项目名称:nunit,代码行数:30,代码来源:TeamCityEventHandler.cs

示例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));
        }
开发者ID:JohanLarsson,项目名称:nunit,代码行数:7,代码来源:TeamCityEventHandler.cs

示例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;
            }
        }
开发者ID:wallymathieu,项目名称:NUnit.Sharepoint.TestRunner,代码行数:58,代码来源:ResultReporter.cs

示例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;
            }
        }
开发者ID:ChrisMaddock,项目名称:nunit,代码行数:54,代码来源:NUnit2ResultSummary.cs

示例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);
        }
开发者ID:ChrisMaddock,项目名称:nunit,代码行数:12,代码来源:NUnit2ResultSummary.cs

示例7: ResultReporter

 public ResultReporter(XmlNode result, ConsoleOptions options)
 {
     this.result = result;
     this.testRunResult = result.GetAttribute("result");
     this.options = options;
     this.summary = new ResultSummary(result);
 }
开发者ID:madmurdock,项目名称:nunit-framework,代码行数:7,代码来源:ResultReporter.cs

示例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;
        }
开发者ID:pampero,项目名称:cgControlPanel,代码行数:46,代码来源:RadioButton.cs

示例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;
 }
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:8,代码来源:JoystickSetupParserXML.cs

示例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);
        }
开发者ID:satish860,项目名称:StructureMap3,代码行数:17,代码来源:PrimitiveArrayReader.cs

示例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;
        }
开发者ID:pampero,项目名称:cgControlPanel,代码行数:45,代码来源:ListBox.cs

示例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"
     };
 }
开发者ID:wukejiong,项目名称:jiongNote,代码行数:14,代码来源:TodoDao.cs

示例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;
        }
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:11,代码来源:JoystickSetupParserXML.cs

示例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;
 }
开发者ID:idaohang,项目名称:Helicopter-Autopilot-Simulator,代码行数:12,代码来源:JoystickSetupParserXML.cs

示例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())
         };
 }
开发者ID:wukejiong,项目名称:jiongNote,代码行数:12,代码来源:NoteDao.cs


注:本文中的System.Xml.XmlNode.GetAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。