Пример #1
0
        /// <summary>
        ///     Returns all ancestor pages for provided page.
        /// </summary>
        /// <param name="page">Page of PageData type for which to return ancestors.</param>
        /// <param name="includeRootPage">True will include root page</param>
        /// <returns>Returns IEnumerable of ancestor pages.</returns>
        public static IEnumerable <PageData> GetAncestors(this PageData page, bool includeRootPage = false)
        {
            while ((page = page.GetParent()) != null)
            {
                if (!includeRootPage && page.ContentLink.Equals(ContentReference.RootPage))
                {
                    yield break;
                }

                yield return(page);
            }
        }
 /// <summary>
 ///     Returns all ancestor pages for provided page.
 /// </summary>
 /// <param name="page">Page of PageData type for which to return ancestors.</param>
 /// <returns>Returns IEnumerable of ancestor pages.</returns>
 public static IEnumerable <PageData> GetAncestors(this PageData page)
 {
     while ((!includeRootPage || page.ParentLink != PageReference.RootPage) && (page = page.GetParent()) != null)
     {
         yield return(page);
     }
 }