<commit_before>using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Ical.Net.Evaluation;
using Ical.Net.Interfaces.DataTypes;
using Ical.Net.Interfaces.General;
using Ical.Net.Serialization.iCalendar.Serializers.DataTypes;
using Ical.Net.Utility;

namespace Ical.Net.DataTypes
{
    /// <summary>
    /// An iCalendar list of recurring dates (or date exclusions)
    /// </summary>
    public class PeriodList : EncodableDataType, IList<Period>
    {
        public string TzId { get; set; }
        public int Count => Periods.Count;

        protected IList<Period> Periods { get; set; } = new List<Period>();

        public PeriodList()
        {
            SetService(new PeriodListEvaluator(this));
        }

        public PeriodList(string value) : this()
        {
            var serializer = new PeriodListSerializer();
            CopyFrom(serializer.Deserialize(new StringReader(value)) as ICopyable);
        }

        public override void CopyFrom(ICopyable obj)
        {
            base.CopyFrom(obj);
            var list = obj as PeriodList;
            if (list == null)
            {
                return;
            }

            foreach (var p in list)
            {
                Add(p);
            }
        }

        public override string ToString() => new PeriodListSerializer().SerializeToString(this);

        public void Add(IDateTime dt) => Periods.Add(new Period(dt));

        public static Dictionary<string, List<Period>> GetGroupedPeriods(IList<PeriodList> periodLists)
        {
            // In order to know if two events are equal, a semantic understanding of exdates, rdates, rrules, and exrules is required. This could be done by
            // computing the complete recurrence set (expensive) while being time-zone sensitive, or by comparing each List<Period> in each IPeriodList.

            // For example, events containing these rules generate the same recurrence set, including having the same time zone for each occurrence, so
            // they're the same:
            // Event A:
            // RDATE:20170302T060000Z,20170303T060000Z
            // Event B:
            // RDATE:20170302T060000Z<commit_msg>Make NetCore PeriodList implement IsReadOnly<commit_after>using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Ical.Net.Evaluation;
using Ical.Net.Interfaces.DataTypes;
using Ical.Net.Interfaces.General;
using Ical.Net.Serialization.iCalendar.Serializers.DataTypes;
using Ical.Net.Utility;

namespace Ical.Net.DataTypes
{
    /// <summary>
    /// An iCalendar list of recurring dates (or date exclusions)
    /// </summary>
    public class PeriodList : EncodableDataType, IList<Period>
    {
        public string TzId { get; set; }
        public int Count => Periods.Count;

        protected IList<Period> Periods { get; set; } = new List<Period>();

        public PeriodList()
        {
            SetService(new PeriodListEvaluator(this));
        }

        public PeriodList(string value) : this()
        {
            var serializer = new PeriodListSerializer();
            CopyFrom(serializer.Deserialize(new StringReader(value)) as ICopyable);
        }

        public override void CopyFrom(ICopyable obj)
        {
            base.CopyFrom(obj);
            var list = obj as PeriodList;
            if (list == null)
            {
                return;
            }

            foreach (var p in list)
            {
                Add(p);
            }
        }
        
        public bool IsReadOnly => Periods.IsReadOnly;

        public override string ToString() => new PeriodListSerializer().SerializeToString(this);

        public void Add(IDateTime dt) => Periods.Add(new Period(dt));

        public static Dictionary<string, List<Period>> GetGroupedPeriods(IList<PeriodList> periodLists)
        {
            // In order to know if two events are equal, a semantic understanding of exdates, rdates, rrules, and exrules is required. This could be done by
            // computing the complete recurrence set (expensive) while being time-zone sensitive, or by comparing each List<Period> in each IPeriodList.

            // For example, events containing these rules generate the same recurrence set, including having the same time zone for each occurrence, so
            // they're the same:
            // Event A:
            // RDATE:20170302T060000Z,20170303T060000Z
            // Event B:
            // RDATE:20170302T060000Z
{'fraction_non_alphanumeric': 0.08697552447552448, 'fraction_numerical': 0.018356643356643356, 'mean_word_length': 2.241501416430595, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 28, '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': '129473', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1193, 'n_words': 371}