<commit_before>﻿using System;
using System.Collections.Generic;
using Baseline;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace Jasper.Settings
{
    public class JasperSettings
    {
        private readonly IList<Action<WebHostBuilderContext>> _configActions = new List<Action<WebHostBuilderContext>>();

        private readonly JasperRegistry _parent;

        private readonly Dictionary<Type, ISettingsBuilder> _settings
            = new Dictionary<Type, ISettingsBuilder>();

        public JasperSettings(JasperRegistry parent)
        {
            _parent = parent;
            Replace<ILoggerFactory>(new LoggerFactory());
        }

        internal bool ApplyingExtensions { get; set; }

        private SettingsBuilder<T> forType<T>(Func<WebHostBuilderContext, T> source = null) where T : class
        {
            if (_settings.ContainsKey(typeof(T)))
            {
                var builder = _settings[typeof(T)].As<SettingsBuilder<T>>();

                if (source != null)
                    builder.Replace(source);

                return builder;
            }
            else
            {
                var builder = new SettingsBuilder<T>(source);
                _settings.Add(typeof(T), builder);

                return builder;
            }
        }


        /// <summary>
        ///     Just directs Jasper to try to read data for T from the IConfiguration<commit_msg>fixed the logging configuration issue that was stopping it from working<commit_after>﻿using System;
using System.Collections.Generic;
using Baseline;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace Jasper.Settings
{
    public class JasperSettings
    {
        private readonly IList<Action<WebHostBuilderContext>> _configActions = new List<Action<WebHostBuilderContext>>();

        private readonly JasperRegistry _parent;

        private readonly Dictionary<Type, ISettingsBuilder> _settings
            = new Dictionary<Type, ISettingsBuilder>();

        public JasperSettings(JasperRegistry parent)
        {
            _parent = parent;
        }

        internal bool ApplyingExtensions { get; set; }

        private SettingsBuilder<T> forType<T>(Func<WebHostBuilderContext, T> source = null) where T : class
        {
            if (_settings.ContainsKey(typeof(T)))
            {
                var builder = _settings[typeof(T)].As<SettingsBuilder<T>>();

                if (source != null)
                    builder.Replace(source);

                return builder;
            }
            else
            {
                var builder = new SettingsBuilder<T>(source);
                _settings.Add(typeof(T), builder);

                return builder;
            }
        }


        /// <summary>
        ///     Just directs Jasper to try to read data for T from the IConfiguration
{'fraction_non_alphanumeric': 0.08428475486903962, 'fraction_numerical': 0.0, 'mean_word_length': 2.159066808059385, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, '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': '2540986', 'n_tokens_mistral': 731, 'n_tokens_neox': 691, 'n_words': 187}