<commit_before>﻿using RJP.MultiUrlPicker.Models;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Razor.Generator;
using Umbraco.Core.Models;
using Umbraco.Web;

namespace Endzone.Umbraco.Extensions.PublishedContentExtensions
{
    public static class MultiUrlPicker
    {

        /// <summary>
        /// (typed) Works for SingleUrlPicker and MultiUrlPicker 
        ///  returns empty List of Link if property not found or empty 
        /// </summary>
        public static IEnumerable<Link> GetLinks(this IPublishedContent content, string property, bool recursive = false)
        {
            var list = content.GetPropertyValue<IEnumerable<Link>>(property, recursive);
            //as of v2.0.0 RJP.MultiURLPicker returns a null IEnumerable when max number of items set to 1
            //  so to support both in this method we need to check for null and if so check for a simgle Link
            if (list == null)
            {
                var singleUrl = content.GetPropertyValue<Link>(property, recursive);
                list = (singleUrl==null) ? Enumerable.Empty<Link>() : new List<Link> { singleUrl };
            }
            return list;
        }

        /// <summary>
        /// (typed) Works for SingleUrlPicker and MultiUrlPicker. Returns the first link.
        /// </summary>
        public static Link GetLink(this IPublishedContent content, string property, bool recursive = false)
        {
            var list = content.GetLinks(property, recursive);
            return list.FirstOrDefault();
        }

        /// <summary>
        /// Gets the links as a collection of IPublishedContent. Check for null.
        /// </summary>
        /// <param name="content"></param>
        /// <param name="property"></param>
        /// <param name="recursive"></param>
        /// <returns></returns>
        public static IEnumerable<IPublishedContent> GetLinksContent(this IPublishedContent content, string property, bool recursive = false)
        {
            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            var links = content.GetLinks(property, recursive);
            var linksContent = new List<IPublishedContent>();
            foreach (var link in links)
            {<commit_msg>Removed wrong method description.<commit_after>﻿using RJP.MultiUrlPicker.Models;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Razor.Generator;
using Umbraco.Core.Models;
using Umbraco.Web;

namespace Endzone.Umbraco.Extensions.PublishedContentExtensions
{
    public static class MultiUrlPicker
    {

        /// <summary>
        /// (typed) Works for SingleUrlPicker and MultiUrlPicker 
        ///  returns empty List of Link if property not found or empty 
        /// </summary>
        public static IEnumerable<Link> GetLinks(this IPublishedContent content, string property, bool recursive = false)
        {
            var list = content.GetPropertyValue<IEnumerable<Link>>(property, recursive);
            //as of v2.0.0 RJP.MultiURLPicker returns a null IEnumerable when max number of items set to 1
            //  so to support both in this method we need to check for null and if so check for a simgle Link
            if (list == null)
            {
                var singleUrl = content.GetPropertyValue<Link>(property, recursive);
                list = (singleUrl==null) ? Enumerable.Empty<Link>() : new List<Link> { singleUrl };
            }
            return list;
        }

        /// <summary>
        /// (typed) Works for SingleUrlPicker and MultiUrlPicker. Returns the first link.
        /// </summary>
        public static Link GetLink(this IPublishedContent content, string property, bool recursive = false)
        {
            var list = content.GetLinks(property, recursive);
            return list.FirstOrDefault();
        }

        /// <summary>
        /// Gets the links as a collection of IPublishedContent.
        /// </summary>
        /// <param name="content"></param>
        /// <param name="property"></param>
        /// <param name="recursive"></param>
        /// <returns></returns>
        public static IEnumerable<IPublishedContent> GetLinksContent(this IPublishedContent content, string property, bool recursive = false)
        {
            var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            var links = content.GetLinks(property, recursive);
            var linksContent = new List<IPublishedContent>();
            foreach (var link in links)
            {
{'fraction_non_alphanumeric': 0.09867009867009867, 'fraction_numerical': 0.001716001716001716, 'mean_word_length': 2.314143567874911, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 47, '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': '6890639', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1158, 'n_words': 374}