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

namespace Geta.EPi.Extensions
{
    public static class LinkItemCollectionExtensions
    {
        /// <summary>
        ///     Returns a PageDataCollection with all the EPiServer pages from a LinkItemCollection.
        /// </summary>
        /// <param name="linkItemCollection">Source LinkItemCollection to look for EPiServer pages.</param>
        /// <returns>PageDataCollection with EPiServer pages from a LinkItemCollection.</returns>
        public static PageDataCollection ToPageDataCollection(this LinkItemCollection linkItemCollection)
        {
            return new PageDataCollection(linkItemCollection.ToEnumerable<PageData>());
        }

        /// <summary>
        ///     Returns a sequence with all the EPiServer pages of given type <typeparamref name="T"/> in a LinkItemCollection
        /// </summary>
        /// <param name="linkItemCollection">Source LinkItemCollection to look for EPiServer pages.</param>
        /// <returns>Sequence of the EPiServer pages of type <typeparamref name="T"/> in a LinkItemCollection</returns>
        public static IEnumerable<T> ToEnumerable<T>(this LinkItemCollection linkItemCollection) 
            where T : PageData
        {
            if (linkItemCollection == null)
            {<commit_msg>Refactoring of LinkItem collection extensions<commit_after>﻿using System.Collections.Generic;
using System.Linq;
using EPiServer;
using EPiServer.Core;
using EPiServer.ServiceLocation;
using EPiServer.SpecializedProperties;

namespace Geta.EPi.Extensions
{
    public static class LinkItemCollectionExtensions
    {
        /// <summary>
        ///     Returns a PageDataCollection with all the EPiServer pages from a LinkItemCollection.
        /// </summary>
        /// <param name="linkItemCollection">Source LinkItemCollection to look for EPiServer pages.</param>
        /// <returns>PageDataCollection with EPiServer pages from a LinkItemCollection.</returns>
        public static PageDataCollection ToPageDataCollection(this LinkItemCollection linkItemCollection)
        {
            return linkItemCollection.ToEnumerable<PageData>().ToPageDataCollection();
        }

        /// <summary>
        ///     Returns a sequence with all the EPiServer pages of given type <typeparamref name="T"/> in a LinkItemCollection
        /// </summary>
        /// <param name="linkItemCollection">Source LinkItemCollection to look for EPiServer pages.</param>
        /// <returns>Sequence of the EPiServer pages of type <typeparamref name="T"/> in a LinkItemCollection</returns>
        public static IEnumerable<T> ToEnumerable<T>(this LinkItemCollection linkItemCollection) 
            where T : PageData
        {
            if (linkItemCollection == null)
            {
{'fraction_non_alphanumeric': 0.08723693143245079, 'fraction_numerical': 0.0, 'mean_word_length': 3.048076923076923, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, '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': '1455533', 'n_tokens_mistral': 716, 'n_tokens_neox': 713, 'n_words': 215}