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


C# XPathNavigator.ReplaceSelf方法代码示例

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


在下文中一共展示了XPathNavigator.ReplaceSelf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: WriteObject

		public bool WriteObject(XPathResult result, XPathNavigator node, object value)
		{
			var xml = new StringBuilder();
			var settings = new XmlWriterSettings
			{
				OmitXmlDeclaration = true,
				Indent = false
			};

			using (var writer = XmlWriter.Create(xml, settings))
			{
				if (value is IXmlSerializable)
				{
					SerializeCustom(writer, result, node, (IXmlSerializable)value);
				}
				else
				{
					Serialize(writer, result, node, value);
				}
				writer.Flush();
			}

			node.ReplaceSelf(xml.ToString());
			return true;
		}
开发者ID:Orvid,项目名称:NAntUniversalTasks,代码行数:25,代码来源:DefaultXmlSerializer.cs

示例3: WriteObject

		public bool WriteObject(XPathResult result, XPathNavigator node, object value)
		{
			var rootOverride = new XmlRootAttribute(node.LocalName)
			{
				Namespace = node.NamespaceURI
			};

			var xml = new StringBuilder();
			var settings = new XmlWriterSettings
			{
				OmitXmlDeclaration = true,
				Indent = false
			};
			var namespaces = new XmlSerializerNamespaces();
			namespaces.Add(string.Empty, string.Empty);
			if (string.IsNullOrEmpty(node.NamespaceURI) == false)
			{
				var prefix = result.Context.AddNamespace(node.NamespaceURI);
				namespaces.Add(prefix, node.NamespaceURI);
			}

			var serializer = new XmlSerializer(result.Type, rootOverride);

			using (var writer = XmlWriter.Create(xml, settings))
			{
				serializer.Serialize(writer, value, namespaces);
				writer.Flush();
			}

			node.ReplaceSelf(xml.ToString());

			return true;
		}
开发者ID:ThatExtraBit,项目名称:Castle.Core,代码行数:33,代码来源:DefaultXmlSerializer.cs


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