<commit_before>﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using EPiServer;
using EPiServer.Core;
using EPiServer.ServiceLocation;
using EPiServer.Web.Routing;

namespace Geta.EPi.Extensions
{
    /// <summary>
    ///     Extension methods for PageData
    /// </summary>
    public static class PageDataExtensions
    {
        /// <summary>
        ///     Returns all child pages of PageData type for provided parent page.
        /// </summary>
        /// <param name="parentPage">Parent page of PageData type for which to return children.</param>
        /// <returns>Returns PageDataCollection of child pages.</returns>
        public static PageDataCollection GetChildren(this PageData parentPage)
        {
            return parentPage.GetChildren<PageData>().ToPageDataCollection();
        }

        /// <summary>
        ///     Returns all child pages of <typeparamref name="T" /> for provided parent page.
        /// </summary>
        /// <typeparam name="T">The type of child pages to return.</typeparam>
        /// <param name="parentPage">Parent page of PageData type for which to return children.</param>
        /// <returns>Returns sequence of child pages of <typeparamref name="T" /> for provided parent page.</returns>
        public static IEnumerable<T> GetChildren<T>(this PageData parentPage)
            where T : PageData
        {<commit_msg>Implementation of GetAncestors<commit_after>﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using EPiServer;
using EPiServer.Core;
using EPiServer.ServiceLocation;
using EPiServer.Web.Routing;

namespace Geta.EPi.Extensions
{
    /// <summary>
    ///     Extension methods for PageData
    /// </summary>
    public static class PageDataExtensions
    {
        /// <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 ((page = page.GetParent()) != null)
            {
                yield return page;
            }
        }

        /// <summary>
        ///     Returns all child pages of PageData type for provided parent page.
        /// </summary>
        /// <param name="parentPage">Parent page of PageData type for which to return children.</param>
        /// <returns>Returns PageDataCollection of child pages.</returns>
        public static PageDataCollection GetChildren(this PageData parentPage)
        {
            return parentPage.GetChildren<PageData>().ToPageDataCollection();
        }

        /// <summary>
        ///     Returns all child pages of <typeparamref name="T" /> for provided parent page.
        /// </summary>
        /// <typeparam name="T">The type of child pages to return.</typeparam>
        /// <param name="parentPage">Parent page of PageData type for which to return children.</param>
        /// <returns>Returns sequence of child pages of <typeparamref name="T" /> for provided parent page.</returns>
        public static IEnumerable<T> GetChildren<T>(this PageData parentPage)
            where T : PageData
        {
{'fraction_non_alphanumeric': 0.10997288339861404, 'fraction_numerical': 0.0, 'mean_word_length': 2.3739837398373984, 'pattern_counts': {'":': 0, '<': 52, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6600870', 'n_tokens_mistral': 836, 'n_tokens_neox': 835, 'n_words': 271}