<commit_before>﻿using System;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace CondenserDotNet.Configuration
{
    public static class ServiceCollectionExtensions
    {

        public static IServiceCollection ConfigureReloadable<TConfig>(this IServiceCollection self, IConfigurationRegistry registry)
            where TConfig : class =>
                self.ConfigureReloadable<TConfig>(registry, typeof(TConfig).Name);

        public static IServiceCollection ConfigureReloadable<TConfig>(this IServiceCollection self, IConfigurationRegistry registry, string sectionName)
            where TConfig : class
        {
            var initialised = false;
            self.Configure<TConfig>
            (config =>
            {
                Action bind = () =>
                {
                    var section = registry.Root.GetSection(sectionName);
                    section.Bind(config);
                };
                if (!initialised)
                {
                    registry.AddWatchOnEntireConfig(bind);
                    initialised = true;
                }
                bind();
            });<commit_msg>add previous methods<commit_after>﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace CondenserDotNet.Configuration
{
    public static class ServiceCollectionExtensions
    {
        public static IServiceCollection ConfigureReloadable<TConfig>(this IServiceCollection self,
            IConfigurationRegistry registry)
            where TConfig : class
        {
            return self.ConfigureReloadable<TConfig>(registry.Root, registry, typeof(TConfig).Name);
        }

        public static IServiceCollection ConfigureReloadable<TConfig>(this IServiceCollection self,
            IConfigurationRegistry registry, string sectionName)
            where TConfig : class
        {
            return self.ConfigureReloadable<TConfig>(registry.Root, registry, sectionName);
        }


        public static IServiceCollection ConfigureReloadable<TConfig>(this IServiceCollection self,
            IConfiguration configuration, IConfigurationRegistry registry)
            where TConfig : class
        {
            return self.ConfigureReloadable<TConfig>(configuration, registry, typeof(TConfig).Name);
        }

        public static IServiceCollection ConfigureReloadable<TConfig>(this IServiceCollection self,
            IConfiguration configuration, IConfigurationRegistry registry, string sectionName)
            where TConfig : class
        {
            var initialised = false;
            self.Configure<TConfig>
            (config =>
            {
                void Bind()
                {
                    var section = configuration.GetSection(sectionName);
                    section.Bind(config);
                }

                if (!initialised)
                {
                    registry.AddWatchOnEntireConfig(Bind);
                    initialised = true;
                }
                Bind();
            });
{'fraction_non_alphanumeric': 0.06550500161342368, 'fraction_numerical': 0.0, 'mean_word_length': 2.0097087378640777, 'pattern_counts': {'":': 0, '<': 15, '<?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': '4939550', 'n_tokens_mistral': 691, 'n_tokens_neox': 659, 'n_words': 148}