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


C# XPathNavigator.AppendChild方法代码示例

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


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

示例1: ProcessItemGroupNode

        private static bool ProcessItemGroupNode(XPathNavigator nav)
        {
            try
            {
                if (nav.MoveToChild("StyleCopTreatErrorsAsWarnings", "http://schemas.microsoft.com/developer/msbuild/2003"))
                {
                    if (nav.Value == "false")
                    {
                        nav.ReplaceSelf("<StyleCopTreatErrorsAsWarnings>true</StyleCopTreatErrorsAsWarnings>");
                    }
                    else
                    {
                        nav.ReplaceSelf("<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>");
                    }
                }
                else
                {
                    nav.AppendChild("<StyleCopTreatErrorsAsWarnings>true</StyleCopTreatErrorsAsWarnings>");
                }

                return true;
            }
            catch
            {
                return false;
            }
        }
开发者ID:julplee,项目名称:StyleCopToggleWarningsAsErrors,代码行数:27,代码来源:Program.cs

示例2: UpdateNode

        /// <summary>
        /// Updates the node replacing inheritdoc node with comments found.
        /// </summary>
        /// <param name="inheritDocNodeNavigator">Navigator for inheritdoc node</param>
        /// <param name="contentNodeNavigator">Navigator for content</param>
        private void UpdateNode(XPathNavigator inheritDocNodeNavigator, XPathNavigator contentNodeNavigator)
        {
            // retrieve the selection filter if specified.
            string selectValue = inheritDocNodeNavigator.GetAttribute("select", string.Empty);

            if(!string.IsNullOrEmpty(selectValue))
                sourceExpression = XPathExpression.Compile(selectValue);

            inheritDocNodeNavigator.MoveToParent();

            if(inheritDocNodeNavigator.LocalName != "comments" && inheritDocNodeNavigator.LocalName != "element")
                sourceExpression = XPathExpression.Compile(inheritDocNodeNavigator.LocalName);
            else
                inheritDocNodeNavigator.MoveTo(this.sourceDocument.CreateNavigator().SelectSingleNode(inheritDocExpression));

            XPathNodeIterator sources = (XPathNodeIterator)contentNodeNavigator.CreateNavigator().Evaluate(sourceExpression);
            inheritDocNodeNavigator.DeleteSelf();

            // append the source nodes to the target node
            foreach(XPathNavigator source in sources)
                inheritDocNodeNavigator.AppendChild(source);
        }
开发者ID:armin-bauer,项目名称:SHFB,代码行数:27,代码来源:InheritDocumentationComponent.cs

示例3: WriteApiPlatforms

        private void WriteApiPlatforms(XPathNavigator referenceNode, string apiGroup, string topicTypeName, string topicNamespaceName)
        {
            XPathNodeIterator versionNodes = referenceNode.Select(versionNodesExpression);
            List<string> supportedPlatforms = new List<string>();
            XmlWriter platformsWriter = referenceNode.AppendChild();
            
            foreach (string platformId in versionFilters.Keys)
            {
                Dictionary<string, VersionFilter> filters = versionFilters[platformId];
                bool included = false;
                foreach (XPathNavigator versionNode in versionNodes)
                {
                    string versionId = versionNode.GetAttribute("name", string.Empty);
                    VersionFilter filter;
                    if (filters.TryGetValue(versionId, out filter))
                    {
                        switch (apiGroup)
                        {
                            case "type":
                                included = filter.IsIncludedType(referenceNode, topicNamespaceName);
                                break;

                            case "member":
                                included = filter.IsIncludedMember(referenceNode, topicTypeName, topicNamespaceName);
                                break;
                        }
                    }
                    if (included)
                        break;
                }

                if (included)
                    supportedPlatforms.Add(platformId);
            }
            platformsWriter.WriteStartElement("platforms");
            foreach (string platformId in supportedPlatforms)
            {
                platformsWriter.WriteElementString("platform", platformId);
            }
            platformsWriter.WriteEndElement();
            platformsWriter.Close();
        }
开发者ID:modulexcite,项目名称:SHFB-1,代码行数:42,代码来源:PlatformsComponent.cs

示例4: MergeComments

        /// <summary>
        /// Merge the XML comments from one member into another
        /// </summary>
        /// <param name="fromMember">The member from which to merge comments</param>
        /// <param name="toMember">The member into which the comments merged</param>
        /// <param name="filter">The selection filter</param>
        private static void MergeComments(XPathNavigator fromMember, XPathNavigator toMember, string filter)
        {
            XPathNavigator duplicate;
            string[] dupAttrs = new string[] { "cref", "href", "name", "vref", "xref" };
            string attrValue;

            if(String.IsNullOrEmpty(filter))
                filter = "*";

            // Merge based on the element name
            foreach(XPathNavigator element in fromMember.Select(filter))
                switch(element.Name)
                {
                    case "example":     // Ignore if already present
                    case "exclude":
                    case "filterpriority":
                    case "preliminary":
                    case "summary":
                    case "remarks":
                    case "returns":
                    case "threadsafety":
                    case "value":
                        if(toMember.SelectSingleNode(element.Name) == null)
                            toMember.AppendChild(element);
                        break;

                    case "overloads":
                        // Ignore completely.  We only need one.
                        break;

                    default:
                        if(!element.HasAttributes)
                            toMember.AppendChild(element);
                        else
                        {
                            // Ignore if there is a duplicate by attribute
                            // name and value.
                            duplicate = null;

                            foreach(string attrName in dupAttrs)
                            {
                                attrValue = element.GetAttribute(attrName, String.Empty);

                                if(!String.IsNullOrEmpty(attrValue))
                                {
                                    duplicate = toMember.SelectSingleNode(String.Format(CultureInfo.InvariantCulture,
                                        "{0}[@{1}='{2}']", element.Name, attrName, attrValue));

                                    if(duplicate != null)
                                        break;
                                }
                            }

                            if(duplicate == null)
                                toMember.AppendChild(element);
                        }
                        break;
                }
        }
开发者ID:codemonster234,项目名称:scbuilder,代码行数:65,代码来源:GenerateInheritedDocs.cs

示例5: EnsureChildNode

 private void EnsureChildNode(XPathNavigator parent, string nodeName)
 {
     XPathNavigator child = parent.SelectSingleNode(String.Format("c:{0}", nodeName), _resolver);
     if (child == null)
         parent.AppendChild(String.Format("<{0}/>", nodeName));
 }
开发者ID:mehedi09,项目名称:GridWork,代码行数:6,代码来源:ControllerConfiguration.cs

示例6: createSpecies


//.........这里部分代码省略.........
            String speciesBase = (navLocal.SelectSingleNode("Base") == null) ? String.Empty : navLocal.SelectSingleNode("Base").Value;
            if (navGlobal.SelectSingleNode(String.Format("/Scenario/Species[Name='{0}']", speciesBase)) != null)
            {
                createLink(VSGConfiguration, document, navGlobal.SelectSingleNode("/Scenario").GetAttribute("name", navGlobal.NamespaceURI), cName, speciesBase, "SpeciesType", String.Empty);
                speciesBase = "ExistingSpecies";
            }

            #endregion

            // Create parameters
            #region parameters

            createParameter(VSGConfiguration, document, cName, "Component", "Species.IsWeapon", (navLocal.SelectSingleNode("IsWeapon") == null) ? String.Empty : navLocal.SelectSingleNode("IsWeapon").Value, String.Empty);
            createParameter(VSGConfiguration, document, cName, "Component", "Species.RemoveOnDestruction", (navLocal.SelectSingleNode("RemoveOnDestruction") == null) ? String.Empty : navLocal.SelectSingleNode("RemoveOnDestruction").Value, String.Empty);
            createParameter(VSGConfiguration, document, cName, "Component", "Species.CollisionRadius", (navLocal.SelectSingleNode("Size") == null) ? String.Empty : navLocal.SelectSingleNode("Size").Value, String.Empty);
            switch (speciesBase)
            {
                case "LandObject":
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.LandObject", "true", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.AirObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.SeaObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.ExistingSpecies", "false", String.Empty); 
                    break;

                case "AirObject":
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.LandObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.AirObject", "true", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.SeaObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.ExistingSpecies", "false", String.Empty); 
                    break;

                case "SeaObject":
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.LandObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.AirObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.SeaObject", "true", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.ExistingSpecies", "false", String.Empty); 
                    break;

                case "ExistingSpecies":
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.LandObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.AirObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.SeaObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.ExistingSpecies", "true", String.Empty);
                    break;

                default:
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.LandObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.AirObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.SeaObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.ExistingSpecies", "false", String.Empty); 
                    break;
            }

            // Name States
            // Because of the State to State links we need to create the names first. Then create them. 
            XPathNodeIterator itStates = navLocal.Select("FullyFunctional | DefineState");
            while (itStates.MoveNext())
            {
                if (itStates.Current.SelectSingleNode("State") != null)
                {
                    String stateName = itStates.Current.SelectSingleNode("State").Value;
                    //itStates.Current.SelectSingleNode("State").SetValue(cName + AME.Tools.ImportTool.Delimitter + stateName);
                    itStates.Current.CreateAttribute(String.Empty, "name", itStates.Current.NamespaceURI, cName + AME.Tools.ImportTool.Delimitter + stateName);
                }
                else
                    //itStates.Current.AppendChildElement(String.Empty, "State", String.Empty, cName + AME.Tools.ImportTool.Delimitter + "FullyFunctional");
                    itStates.Current.CreateAttribute(String.Empty, "name", String.Empty, cName + AME.Tools.ImportTool.Delimitter + "FullyFunctional");
            }


            // Create States
            itStates = navLocal.Select("FullyFunctional | DefineState");
            Boolean isDeadState = false;
            while (itStates.MoveNext())
            {
                String stateName = itStates.Current.GetAttribute("name", itStates.Current.NamespaceURI);
                if (stateName.ToLower().Equals(cName.ToLower() + AME.Tools.ImportTool.Delimitter + "Dead".ToLower()))
                    isDeadState = true;
            }
            if (!isDeadState)
            {
                String name = cName + AME.Tools.ImportTool.Delimitter + "Dead";

                XmlElement deadState = document.CreateElement("DefineState");
                XmlAttribute deadStateName = document.CreateAttribute("name");
                deadStateName.InnerXml = name;
                deadState.Attributes.Append(deadStateName);
                XmlElement state = document.CreateElement("State");
                state.InnerXml = name;
                deadState.AppendChild(state);
                navLocal.AppendChild(deadState.CreateNavigator());
            }
            itStates = navLocal.Select("FullyFunctional | DefineState");
            while (itStates.MoveNext())
            {
                createState(itStates.Current, document, navGlobal);
            }

            #endregion
        }
开发者ID:wshanshan,项目名称:DDD,代码行数:101,代码来源:DDD4_0_2_Importer.cs

示例7: createSpecies


//.........这里部分代码省略.........
                    start = rules.IndexOf(">", i-1);
                    end = rules.IndexOf("<", start);
                    if (end - start > 1)
                    {
                        rules = rules.Remove(start + 1, end - start-1);
                    }
                    i = rules.IndexOf("\r\n");                    
                }

                CDRs.Rules = ClassificationDisplayRules.FromXML(rules);
                createParameter(VSGConfiguration, document, cName, "Component", "Species.ClassificationDisplayRules", CDRs.ToXML(), String.Empty);
            }

            createParameter(VSGConfiguration, document, cName, "Component", "Species.CollisionRadius", (navLocal.SelectSingleNode("Size") == null) ? String.Empty : navLocal.SelectSingleNode("Size").Value, String.Empty);
            createParameter(VSGConfiguration, document, cName, "Component", "Species.LaunchedByOwner", (navLocal.SelectSingleNode("LaunchedByOwner") == null) ? String.Empty : navLocal.SelectSingleNode("LaunchedByOwner").Value, String.Empty);
            switch (speciesBase)
            {
                case "LandObject":
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.LandObject", "true", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.AirObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.SeaObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.ExistingSpecies", "false", String.Empty); 
                    break;

                case "AirObject":
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.LandObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.AirObject", "true", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.SeaObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.ExistingSpecies", "false", String.Empty); 
                    break;

                case "SeaObject":
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.LandObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.AirObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.SeaObject", "true", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.ExistingSpecies", "false", String.Empty); 
                    break;

                case "ExistingSpecies":
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.LandObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.AirObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.SeaObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.ExistingSpecies", "true", String.Empty);
                    break;

                default:
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.LandObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.AirObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.SeaObject", "false", String.Empty);
                    createParameter(VSGConfiguration, document, cName, "Component", "Species.ExistingSpecies", "false", String.Empty); 
                    break;
            }

            // Name States
            // Because of the State to State links we need to create the names first. Then create them. 
            XPathNodeIterator itStates = navLocal.Select("FullyFunctional | DefineState");
            while (itStates.MoveNext())
            {
                if (itStates.Current.SelectSingleNode("State") != null)
                {
                    String stateName = itStates.Current.SelectSingleNode("State").Value;
                    //itStates.Current.SelectSingleNode("State").SetValue(cName + AME.Tools.ImportTool.Delimitter + stateName);
                    itStates.Current.CreateAttribute(String.Empty, "name", itStates.Current.NamespaceURI, cName + AME.Tools.ImportTool.Delimitter + stateName);
                }
                else
                    //itStates.Current.AppendChildElement(String.Empty, "State", String.Empty, cName + AME.Tools.ImportTool.Delimitter + "FullyFunctional");
                    itStates.Current.CreateAttribute(String.Empty, "name", String.Empty, cName + AME.Tools.ImportTool.Delimitter + "FullyFunctional");
            }


            // Create States
            itStates = navLocal.Select("FullyFunctional | DefineState");
            Boolean isDeadState = false;
            while (itStates.MoveNext())
            {
                String stateName = itStates.Current.GetAttribute("name", itStates.Current.NamespaceURI);
                if (stateName.ToLower().Equals(cName.ToLower() + AME.Tools.ImportTool.Delimitter + "Dead".ToLower()))
                    isDeadState = true;
            }
            if (!isDeadState)
            {
                String name = cName + AME.Tools.ImportTool.Delimitter + "Dead";

                XmlElement deadState = document.CreateElement("DefineState");
                XmlAttribute deadStateName = document.CreateAttribute("name");
                deadStateName.InnerXml = name;
                deadState.Attributes.Append(deadStateName);
                XmlElement state = document.CreateElement("State");
                state.InnerXml = name;
                deadState.AppendChild(state);
                navLocal.AppendChild(deadState.CreateNavigator());
            }
            itStates = navLocal.Select("FullyFunctional | DefineState");
            while (itStates.MoveNext())
            {
                createState(itStates.Current, document, navGlobal);
            }

            #endregion
        }
开发者ID:wshanshan,项目名称:DDD,代码行数:101,代码来源:DDD4_1_Importer.cs

示例8: Merge

 private static void Merge(XPathNavigator DstNavi, XmlDocument SrcDoc, string Parent)
 {
     var Current = NodePath(Parent, NodeView(DstNavi));
     if (!string.IsNullOrWhiteSpace(Current))
     {
         if (DstNavi.NodeType == XPathNodeType.Element)
         {
             var SrcElem = SrcDoc.SelectSingleNode(Current);
             if (SrcElem != null)
             {
                 var Frozen = GetFrozenAttributes(Current, FrozenAttributes);
                 if (DstNavi.MoveToFirstAttribute())
                 {
                     do
                     {
                         var SrcElemAttr = SrcElem.Attributes[DstNavi.LocalName];
                         if (SrcElemAttr != null && CanProcess(DstNavi.LocalName, Frozen))
                             DstNavi.SetValue(SrcElemAttr.Value);
                     }
                     while (DstNavi.MoveToNextAttribute());
                     DstNavi.MoveToParent();
                 }
             }
         }
         else if (DstNavi.NodeType == XPathNodeType.Text)
         {
             var SrcElem = SrcDoc.SelectSingleNode(Current);
             if (SrcElem != null)
                 DstNavi.SetValue(SrcElem.InnerText);
         }
         if (DstNavi.MoveToFirstChild())
         {
             do
             {
                 Merge(DstNavi, SrcDoc, Current);
             }
             while (DstNavi.MoveToNext());
             DstNavi.MoveToParent();
         }
         else if (DstNavi.NodeType == XPathNodeType.Element)
         {
             var SrcElem = SrcDoc.SelectSingleNode(Current);
             if (SrcElem != null && !string.IsNullOrWhiteSpace(SrcElem.InnerXml))
                 foreach (XmlNode Child in SrcElem.ChildNodes)
                     DstNavi.AppendChild(Child.CloneNode(true).CreateNavigator());
         }
     }
 }
开发者ID:lwhitelock,项目名称:Websitepanel,代码行数:48,代码来源:XmlDocumentMerge.cs


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