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


C# XmlDocument.CreateComment方法代码示例

本文整理汇总了C#中XmlDocument.CreateComment方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDocument.CreateComment方法的具体用法?C# XmlDocument.CreateComment怎么用?C# XmlDocument.CreateComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XmlDocument的用法示例。


在下文中一共展示了XmlDocument.CreateComment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NameOfAllTypes

        public static void NameOfAllTypes()
        {
            var xmlDocument = new XmlDocument();

            var element = xmlDocument.CreateElement("newElem");
            Assert.Equal("newElem", element.Name);

            var attribute = xmlDocument.CreateAttribute("newAttr");
            Assert.Equal("newAttr", attribute.Name);

            var text = xmlDocument.CreateTextNode("");
            Assert.Equal("#text", text.Name);

            var cdata = xmlDocument.CreateCDataSection("");
            Assert.Equal("#cdata-section", cdata.Name);

            var pi = xmlDocument.CreateProcessingInstruction("PI", "");
            Assert.Equal("PI", pi.Name);

            var comment = xmlDocument.CreateComment("some text");
            Assert.Equal("#comment", comment.Name);

            var fragment = xmlDocument.CreateDocumentFragment();
            Assert.Equal("#document-fragment", fragment.Name);
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:25,代码来源:NameTests.cs

示例2: CreateEmptyComment

        public static void CreateEmptyComment()
        {
            var xmlDocument = new XmlDocument();
            var comment = xmlDocument.CreateComment(String.Empty);

            Assert.Equal("<!---->", comment.OuterXml);
            Assert.Equal(String.Empty, comment.InnerText);
            Assert.Equal(comment.NodeType, XmlNodeType.Comment);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:CreateCommentTests.cs

示例3: ImportDocumentFragment

        public static void ImportDocumentFragment()
        {
            var tempDoc = new XmlDocument();
            var nodeToImport = tempDoc.CreateDocumentFragment();

            nodeToImport.AppendChild(tempDoc.CreateElement("A1"));
            nodeToImport.AppendChild(tempDoc.CreateComment("comment"));
            nodeToImport.AppendChild(tempDoc.CreateProcessingInstruction("PI", "donothing"));

            var xmlDocument = new XmlDocument();
            var node = xmlDocument.ImportNode(nodeToImport, true);

            Assert.Equal(xmlDocument, node.OwnerDocument);
            Assert.Equal(XmlNodeType.DocumentFragment, node.NodeType);
            Assert.Equal(nodeToImport.OuterXml, node.OuterXml);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:16,代码来源:ImportNodeTests.cs

示例4: OwnerDocumentOnImportedTree

        public static void OwnerDocumentOnImportedTree()
        {
            var tempDoc = new XmlDocument();
            var nodeToImport = tempDoc.CreateDocumentFragment();

            nodeToImport.AppendChild(tempDoc.CreateElement("A1"));
            nodeToImport.AppendChild(tempDoc.CreateComment("comment"));
            nodeToImport.AppendChild(tempDoc.CreateProcessingInstruction("PI", "donothing"));

            var xmlDocument = new XmlDocument();
            var node = xmlDocument.ImportNode(nodeToImport, true);

            Assert.Equal(xmlDocument, node.OwnerDocument);

            foreach (XmlNode child in node.ChildNodes)
                Assert.Equal(xmlDocument, child.OwnerDocument);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:17,代码来源:OwnerDocumentTests.cs

示例5: CreateNode

        public static XmlNode CreateNode(XmlDocument doc, XmlNodeType nodeType)
        {
            Assert.NotNull(doc);

            switch (nodeType)
            {
                case XmlNodeType.CDATA:
                    return doc.CreateCDataSection(@"&lt; &amp; <tag> < ! > & </tag> 	 ");
                case XmlNodeType.Comment:
                    return doc.CreateComment(@"comment");
                case XmlNodeType.Element:
                    return doc.CreateElement("E");
                case XmlNodeType.Text:
                    return doc.CreateTextNode("text");
                case XmlNodeType.Whitespace:
                    return doc.CreateWhitespace(@"	  ");
                case XmlNodeType.SignificantWhitespace:
                    return doc.CreateSignificantWhitespace("	");
                default:
                    throw new ArgumentException("Wrong XmlNodeType: '" + nodeType + "'");
            }
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:22,代码来源:TestHelper.cs

示例6: CommentNode

        public static void CommentNode()
        {
            var xmlDocument = new XmlDocument();
            var node = xmlDocument.CreateComment("comment");

            Assert.Equal("comment", node.Value);
            node.Value = "new comment";
            Assert.Equal("new comment", node.Value);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:9,代码来源:ValueTests.cs

示例7: ExportInputManager

    public static bool ExportInputManager(RUISInputManager inputManager, string filename)
    {
        XmlDocument xmlDoc = new XmlDocument();

        xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes");

        XmlElement inputManagerRootElement = xmlDoc.CreateElement("ns2", "RUISInputManager", "http://ruisystem.net/RUISInputManager");
        xmlDoc.AppendChild(inputManagerRootElement);

        XmlComment booleanComment = xmlDoc.CreateComment("Boolean values always with a lower case, e.g. \"true\" or \"false\"");
        inputManagerRootElement.AppendChild(booleanComment);

        XmlElement psMoveSettingsElement = xmlDoc.CreateElement("PSMoveSettings");
        inputManagerRootElement.AppendChild(psMoveSettingsElement);

        XmlElement psMoveEnabledElement = xmlDoc.CreateElement("enabled");
        psMoveEnabledElement.SetAttribute("value", inputManager.enablePSMove.ToString().ToLowerInvariant());
        psMoveSettingsElement.AppendChild(psMoveEnabledElement);

        XmlElement psMoveIPElement = xmlDoc.CreateElement("ip");
        psMoveIPElement.SetAttribute("value", inputManager.PSMoveIP.ToString());
        psMoveSettingsElement.AppendChild(psMoveIPElement);

        XmlElement psMovePortElement = xmlDoc.CreateElement("port");
        psMovePortElement.SetAttribute("value", inputManager.PSMovePort.ToString());
        psMoveSettingsElement.AppendChild(psMovePortElement);

        XmlElement psMoveAutoConnectElement = xmlDoc.CreateElement("autoConnect");
        psMoveAutoConnectElement.SetAttribute("value", inputManager.connectToPSMoveOnStartup.ToString().ToLowerInvariant());
        psMoveSettingsElement.AppendChild(psMoveAutoConnectElement);

        XmlElement psMoveEnableInGameCalibration = xmlDoc.CreateElement("enableInGameCalibration");
        psMoveEnableInGameCalibration.SetAttribute("value", inputManager.enableMoveCalibrationDuringPlay.ToString().ToLowerInvariant());
        psMoveSettingsElement.AppendChild(psMoveEnableInGameCalibration);

        XmlElement psMoveMaxControllersElement = xmlDoc.CreateElement("maxControllers");
        psMoveMaxControllersElement.SetAttribute("value", inputManager.amountOfPSMoveControllers.ToString());
        psMoveSettingsElement.AppendChild(psMoveMaxControllersElement);

        XmlElement kinectSettingsElement = xmlDoc.CreateElement("KinectSettings");
        inputManagerRootElement.AppendChild(kinectSettingsElement);

        XmlElement kinectEnabledElement = xmlDoc.CreateElement("enabled");
        kinectEnabledElement.SetAttribute("value", inputManager.enableKinect.ToString().ToLowerInvariant());
        kinectSettingsElement.AppendChild(kinectEnabledElement);

        XmlElement maxKinectPlayersElement = xmlDoc.CreateElement("maxPlayers");
        maxKinectPlayersElement.SetAttribute("value", inputManager.maxNumberOfKinectPlayers.ToString());
        kinectSettingsElement.AppendChild(maxKinectPlayersElement);

        XmlElement kinectFloorDetectionElement = xmlDoc.CreateElement("floorDetection");
        kinectFloorDetectionElement.SetAttribute("value", inputManager.kinectFloorDetection.ToString().ToLowerInvariant());
        kinectSettingsElement.AppendChild(kinectFloorDetectionElement);

        XmlElement jumpGestureElement = xmlDoc.CreateElement("jumpGestureEnabled");
        jumpGestureElement.SetAttribute("value", inputManager.jumpGestureEnabled.ToString().ToLowerInvariant());
        kinectSettingsElement.AppendChild(jumpGestureElement);

        XmlElement kinect2SettingsElement = xmlDoc.CreateElement("Kinect2Settings");
        inputManagerRootElement.AppendChild(kinect2SettingsElement);

        XmlElement kinect2EnabledElement = xmlDoc.CreateElement("enabled");
        kinect2EnabledElement.SetAttribute("value", inputManager.enableKinect2.ToString().ToLowerInvariant());
        kinect2SettingsElement.AppendChild(kinect2EnabledElement);

        XmlElement kinect2FloorDetectionElement = xmlDoc.CreateElement("floorDetection");
        kinect2FloorDetectionElement.SetAttribute("value", inputManager.kinect2FloorDetection.ToString().ToLowerInvariant());
        kinect2SettingsElement.AppendChild(kinect2FloorDetectionElement);

        XmlElement razerSettingsElement = xmlDoc.CreateElement("RazerSettings");
        inputManagerRootElement.AppendChild(razerSettingsElement);

        XmlElement razerEnabledElement = xmlDoc.CreateElement("enabled");
        razerEnabledElement.SetAttribute("value", inputManager.enableRazerHydra.ToString().ToLowerInvariant());
        razerSettingsElement.AppendChild(razerEnabledElement);

        XmlElement riftDriftSettingsElement = xmlDoc.CreateElement("OculusDriftSettings");
        inputManagerRootElement.AppendChild(riftDriftSettingsElement);

        //XmlElement magnetometerDriftCorrectionElement = xmlDoc.CreateElement("magnetometerDriftCorrection");
        //magnetometerDriftCorrectionElement.SetAttribute("value", System.Enum.GetName(typeof(RUISInputManager.RiftMagnetometer), inputManager.riftMagnetometerMode));
        //riftDriftSettingsElement.AppendChild(magnetometerDriftCorrectionElement);

        XmlElement kinectDriftCorrectionElement = xmlDoc.CreateElement("kinectDriftCorrectionIfAvailable");
        kinectDriftCorrectionElement.SetAttribute("value", inputManager.kinectDriftCorrectionPreferred.ToString().ToLowerInvariant());
        riftDriftSettingsElement.AppendChild(kinectDriftCorrectionElement);

        XMLUtil.SaveXmlToFile(filename, xmlDoc);

        return true;
    }
开发者ID:vanstorm9,项目名称:KinectSwordFight,代码行数:91,代码来源:XmlImportExport.cs

示例8: ElementNodeWithOneChildDeleteItInsertTwoNewChildren

        public static void ElementNodeWithOneChildDeleteItInsertTwoNewChildren()
        {
            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml("<top><child /></top>");
            xmlDocument.DocumentElement.RemoveChild(xmlDocument.DocumentElement.FirstChild);

            var newNode1 = xmlDocument.CreateTextNode("text node");
            var newNode2 = xmlDocument.CreateComment("comment here");

            xmlDocument.DocumentElement.AppendChild(newNode1);
            xmlDocument.DocumentElement.AppendChild(newNode2);

            Assert.NotNull(xmlDocument.DocumentElement.FirstChild);
            Assert.Same(newNode1, xmlDocument.DocumentElement.FirstChild);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:15,代码来源:FirstChildTests.cs

示例9: FirstChildOfNewDocumentFragmentWithChildren

        public static void FirstChildOfNewDocumentFragmentWithChildren()
        {
            var xmlDocument = new XmlDocument();
            var fragment = xmlDocument.CreateDocumentFragment();
            var node1 = xmlDocument.CreateComment("comment");
            var node2 = xmlDocument.CreateCDataSection("some random text");

            fragment.AppendChild(node1);
            fragment.AppendChild(node2);

            Assert.Same(node1, fragment.FirstChild);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:12,代码来源:FirstChildTests.cs

示例10: FirstChildOfNewComment

        public static void FirstChildOfNewComment()
        {
            var xmlDocument = new XmlDocument();

            Assert.Null(xmlDocument.CreateComment("a comment").FirstChild);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:6,代码来源:FirstChildTests.cs

示例11: CheckNoChildrenOnComment

 public static void CheckNoChildrenOnComment()
 {
     var xmlDocument = new XmlDocument();
     Assert.False(xmlDocument.CreateComment("info").HasChildNodes);
 }
开发者ID:noahfalk,项目名称:corefx,代码行数:5,代码来源:HasChildNodesTests.cs

示例12: NewlyCreatedComment

        public static void NewlyCreatedComment()
        {
            var xmlDocument = new XmlDocument();
            var node = xmlDocument.CreateComment("comment");

            Assert.Null(node.NextSibling);
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:7,代码来源:NextSiblingTests.cs

示例13: CommentChildNodeCount

        public static void CommentChildNodeCount()
        {
            var xmlDocument = new XmlDocument();
            var item = xmlDocument.CreateComment("comment");
            var clonedTrue = item.CloneNode(true);
            var clonedFalse = item.CloneNode(false);

            Assert.Equal(0, item.ChildNodes.Count);
            Assert.Equal(0, clonedTrue.ChildNodes.Count);
            Assert.Equal(0, clonedFalse.ChildNodes.Count);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:11,代码来源:ChildNodesTests.cs

示例14: InsertCommentNodeToDocument

        public static void InsertCommentNodeToDocument()
        {
            var xmlDocument = new XmlDocument();
            xmlDocument.LoadXml("<root/>");

            var node = xmlDocument.CreateComment("some comment");

            Assert.Equal(0, xmlDocument.DocumentElement.ChildNodes.Count);

            var result = xmlDocument.DocumentElement.InsertBefore(node, null);

            Assert.Same(node, result);
            Assert.Equal(1, xmlDocument.DocumentElement.ChildNodes.Count);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:14,代码来源:InsertBeforeTests.cs

示例15: InsertCommentNodeToDocumentFragment

        public static void InsertCommentNodeToDocumentFragment()
        {
            var xmlDocument = new XmlDocument();
            var documentFragment = xmlDocument.CreateDocumentFragment();
            var node = xmlDocument.CreateComment("some comment");

            Assert.Equal(0, documentFragment.ChildNodes.Count);

            var result = documentFragment.InsertBefore(node, null);

            Assert.Same(node, result);
            Assert.Equal(1, documentFragment.ChildNodes.Count);
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:13,代码来源:InsertBeforeTests.cs


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