<commit_before>﻿using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace MediaPlayer.Serializable
{
    /**
     * Simple helper class used for serialization corresponding to the content of a directory
     **/
    [Serializable]
    public class MediaList
    {
        private MediaList sorted = null;

        private List<DirectoryContent> content = new List<DirectoryContent>();
        private List<string> directories = new List<string>();

        private string rootDirectory;

        public MediaList Sorted
        {
            get { return (sorted == null ? this : sorted); }
        }

        public static MediaList operator +(MediaList a, MediaList b)
        {
            return new MediaList(a.Content.Concat(b.Content).ToList());
        }

        public List<string> GetAll<T>(string property)
        {
            var prop = typeof(T).GetProperty(property);

            var lst = Content.SelectMany(delegate(DirectoryContent directory)
            {
                return (directory.List.Select(media => prop.GetValue(media).ToString()));
            }).Distinct().ToList();

            return lst;
        }
<commit_msg>GetAll is now safe :p<commit_after>﻿using System;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace MediaPlayer.Serializable
{
    /**
     * Simple helper class used for serialization corresponding to the content of a directory
     **/
    [Serializable]
    public class MediaList
    {
        private MediaList sorted = null;

        private List<DirectoryContent> content = new List<DirectoryContent>();
        private List<string> directories = new List<string>();

        private string rootDirectory;

        public MediaList Sorted
        {
            get { return (sorted == null ? this : sorted); }
        }

        public static MediaList operator +(MediaList a, MediaList b)
        {
            return new MediaList(a.Content.Concat(b.Content).ToList());
        }

        public List<string> GetAll<T>(string property)
        {
            var prop = typeof(T).GetProperty(property);

            var lst = Content.SelectMany(delegate(DirectoryContent directory)
            {
                try
                {
                    return (directory.List.Select(media => prop.GetValue(media).ToString()));
                }
                catch (NullReferenceException e)
                {
                    return (null);
                }
            }).Distinct().ToList();

            return lst;
        }

{'fraction_non_alphanumeric': 0.09472161966738973, 'fraction_numerical': 0.0, 'mean_word_length': 2.140749148694665, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, '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': '4118118', 'n_tokens_mistral': 696, 'n_tokens_neox': 676, 'n_words': 184}