예제 #1
0
 public static IEnumerable <AspxNode> ElementsBeforeSelf(this AspxNode item)
 {
     if (item.Ancestors().FirstOrDefault() == null)
     {
         yield break;
     }
     foreach (var child in item.Ancestors().First().Elements())
     {
         if (item.Equals(child))
         {
             break;
         }
         yield return(child);
     }
 }
예제 #2
0
        public static IEnumerable <AspxNode> AncestorsAndSelf(this AspxNode item)
        {
            yield return(item);

            foreach (var ancestor in item.Ancestors())
            {
                yield return(ancestor);
            }
        }
예제 #3
0
        public static IEnumerable <AspxNode> ElementsAfterSelf(this AspxNode item)
        {
            if (item.Ancestors().FirstOrDefault() == null)
            {
                yield break;
            }
            bool afterSelf = false;

            foreach (var child in item.Ancestors().First().Elements())
            {
                if (afterSelf)
                {
                    yield return(child);
                }

                if (item.Equals(child))
                {
                    afterSelf = true;
                }
            }
        }
예제 #4
0
 public static IEnumerable <T> Ancestors <T>(this AspxNode item)
 {
     return(item.Ancestors().Where(i => i is T).Cast <T>());
 }