<commit_before>﻿// <copyright file="BasicConfigurator.cs" company="ConfigR contributors">
//  Copyright (c) ConfigR contributors. (<EMAIL>)
// </copyright>

namespace ConfigR
{
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;
    using Common.Logging;
    using ServiceStack.Text;

    public class BasicConfigurator : IConfigurator
    {
        private static readonly ILog log = LogManager.GetCurrentClassLogger();
        private readonly Dictionary<string, dynamic> configuration = new Dictionary<string, dynamic>();

        public IEnumerable<KeyValuePair<string, dynamic>> Items
        {
            get { return this.configuration.Select(item => item); }
        }

        public dynamic this[string key]
        {
            get { return this.configuration[key]; }
        }

        public virtual IConfigurator Load()
        {
            return this;
        }

        public IConfigurator Add(string key, dynamic value)
        {
            log.DebugFormat(CultureInfo.InvariantCulture, "Adding '{0}': {1}", key, StringExtensions.ToJsv(value));
            this.configuration.Add(key, value);
            return this;
        }

        public bool TryGet(string key, out dynamic value)
        {
            return this.configuration.TryGetValue(key, out value);
        }
    }
}<commit_msg>#52 added workaround for ServiceStack bug<commit_after>﻿// <copyright file="BasicConfigurator.cs" company="ConfigR contributors">
//  Copyright (c) ConfigR contributors. (<EMAIL>)
// </copyright>

namespace ConfigR
{
    using System;
    using System.Collections.Generic;
    using System.Diagnostics.CodeAnalysis;
    using System.Globalization;
    using System.Linq;
    using Common.Logging;
    using ServiceStack.Text;

    public class BasicConfigurator : IConfigurator
    {
        private static readonly ILog log = LogManager.GetCurrentClassLogger();
        private readonly Dictionary<string, dynamic> configuration = new Dictionary<string, dynamic>();

        public IEnumerable<KeyValuePair<string, dynamic>> Items
        {
            get { return this.configuration.Select(item => item); }
        }

        public dynamic this[string key]
        {
            get { return this.configuration[key]; }
        }

        public virtual IConfigurator Load()
        {
            return this;
        }

        public IConfigurator Add(string key, dynamic value)
        {
            log.DebugFormat(CultureInfo.InvariantCulture, "Adding '{0}': {1}", key, ToJsv(value));
            this.configuration.Add(key, value);
            return this;
        }

        public bool TryGet(string key, out dynamic value)
        {
            return this.configuration.TryGetValue(key, out value);
        }

        [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Safe in this case.")]
        private static string ToJsv(dynamic value)
        {
            try
            {
                return StringExtensions.ToJsv(value);
            }
            catch (Exception)
            {
                return StringExtensions.ToJsv(value.GetType());
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09644194756554307, 'fraction_numerical': 0.003121098626716604, 'mean_word_length': 2.2604272634791456, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 19, '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': '3930333', 'n_tokens_mistral': 832, 'n_tokens_neox': 809, 'n_words': 206}