System.Xml.XPath.XPathNavigator.ReplaceSelf C# (CSharp) Метод

ReplaceSelf() публичный Метод

public ReplaceSelf ( XmlReader newNode ) : void
newNode XmlReader
Результат void
        public virtual void ReplaceSelf(XmlReader newNode)
        {
            if (newNode == null)
            {
                throw new ArgumentNullException(nameof(newNode));
            }
            XPathNodeType type = NodeType;
            if (type == XPathNodeType.Root
                || type == XPathNodeType.Attribute
                || type == XPathNodeType.Namespace)
            {
                throw new InvalidOperationException(SR.Xpn_BadPosition);
            }
            XmlWriter writer = ReplaceRange(this);
            BuildSubtree(newNode, writer);
            writer.Close();
        }

Same methods

XPathNavigator::ReplaceSelf ( XPathNavigator newNode ) : void
XPathNavigator::ReplaceSelf ( string newNode ) : void

Usage Example

        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;
            }
        }
All Usage Examples Of System.Xml.XPath.XPathNavigator::ReplaceSelf