Пример #1
0
 public override bool ReadToNextSibling(string localName, string namespaceName)
 {
     if (!IsInteractive)
     {
         return(false);
     }
     MoveToElement();
     if (source != root)
     {
         XNode n = source as XNode;
         if (n != null)
         {
             foreach (XElement e in n.ElementsAfterSelf())
             {
                 if (e.Name.LocalName == localName &&
                     e.Name.NamespaceName == namespaceName)
                 {
                     source       = e;
                     IsEndElement = false;
                     return(true);
                 }
             }
             if (n.parent is XElement)
             {
                 source       = n.parent;
                 IsEndElement = true;
                 return(false);
             }
         }
         else
         {
             if (parent is XElement)
             {
                 source       = parent;
                 parent       = null;
                 IsEndElement = true;
                 return(false);
             }
         }
     }
     return(ReadToEnd());
 }
Пример #2
0
 public override bool ReadToNextSibling(string localName, string namespaceName)
 {
     if (!this.IsInteractive)
     {
         return(false);
     }
     this.MoveToElement();
     if (this.source != this.root)
     {
         XNode source = this.source as XNode;
         if (source != null)
         {
             foreach (XElement element in source.ElementsAfterSelf())
             {
                 if ((element.Name.LocalName == localName) && (element.Name.NamespaceName == namespaceName))
                 {
                     this.source       = element;
                     this.IsEndElement = false;
                     return(true);
                 }
             }
             if (source.parent is XElement)
             {
                 this.source       = source.parent;
                 this.IsEndElement = true;
                 return(false);
             }
         }
         else if (this.parent is XElement)
         {
             this.source       = this.parent;
             this.parent       = null;
             this.IsEndElement = true;
             return(false);
         }
     }
     return(this.ReadToEnd());
 }
Пример #3
0
        internal static void RemoveIndented(XNode element)
        {
            // NOTE: this method is tested by BindinRedirectManagerTest and SettingsTest
            var textBeforeOrNull = element.PreviousNode as XText;
            var textAfterOrNull = element.NextNode as XText;
            var oneIndentLevel = ComputeOneLevelOfIndentation(element);
            var isLastChild = !element.ElementsAfterSelf().Any();

            element.Remove();

            if (textAfterOrNull != null
                && IsWhiteSpace(textAfterOrNull))
            {
                textAfterOrNull.Remove();
            }

            if (isLastChild
                && textBeforeOrNull != null
                && IsWhiteSpace(textAfterOrNull))
            {
                textBeforeOrNull.Value = textBeforeOrNull.Value.Substring(0, textBeforeOrNull.Value.Length - oneIndentLevel.Length);
            }
        }