<commit_before>﻿using System;
using System.Collections.Generic;

namespace Atata
{
    public static class LogConsumerAliases
    {
        public const string Trace = "trace";

        public const string Debug = "debug";

        public const string Console = "console";

        public const string NUnit = "nunit";

        public const string NLog = "nlog";

        private static readonly Dictionary<string, Func<ILogConsumer>> AliasFactoryMap = new Dictionary<string, Func<ILogConsumer>>(StringComparer.OrdinalIgnoreCase);

        static LogConsumerAliases()
        {
            Register<TraceLogConsumer>(Trace);
            Register<DebugLogConsumer>(Debug);
            Register<ConsoleLogConsumer>(Console);
            Register<NUnitTestContextLogConsumer>(NUnit);
            Register<NLogConsumer>(NLog);
        }

        public static void Register<T>(string typeAlias)
            where T : ILogConsumer, new()
        {
            Register(typeAlias, () => new T());
        }

        public static void Register(string typeAlias, Func<ILogConsumer> logConsumerFactory)
        {
            typeAlias.CheckNotNullOrWhitespace(nameof(typeAlias));
            logConsumerFactory.CheckNotNull(nameof(logConsumerFactory));

            AliasFactoryMap[typeAlias.ToLower()] = logConsumerFactory;
        }

        public static ILogConsumer Resolve(string typeNameOrAlias)
        {
            typeNameOrAlias.CheckNotNullOrWhitespace(nameof(typeNameOrAlias));

            return AliasFactoryMap.TryGetValue(typeNameOrAlias, out Func<ILogConsumer> factory)
                ? factory()
                : ActivatorEx.CreateInstance<ILogConsumer>(typeNameOrAlias);
        }
    }
}<commit_msg>#353 Add log4net log consumer: - Add to LogConsumerAliases<commit_after>﻿using System;
using System.Collections.Generic;

namespace Atata
{
    public static class LogConsumerAliases
    {
        public const string Trace = "trace";

        public const string Debug = "debug";

        public const string Console = "console";

        public const string NUnit = "nunit";

        public const string NLog = "nlog";

        public const string Log4Net = "log4net";

        private static readonly Dictionary<string, Func<ILogConsumer>> AliasFactoryMap = new Dictionary<string, Func<ILogConsumer>>(StringComparer.OrdinalIgnoreCase);

        static LogConsumerAliases()
        {
            Register<TraceLogConsumer>(Trace);
            Register<DebugLogConsumer>(Debug);
            Register<ConsoleLogConsumer>(Console);
            Register<NUnitTestContextLogConsumer>(NUnit);
            Register<NLogConsumer>(NLog);
            Register<Log4NetConsumer>(Log4Net);
        }

        public static void Register<T>(string typeAlias)
            where T : ILogConsumer, new()
        {
            Register(typeAlias, () => new T());
        }

        public static void Register(string typeAlias, Func<ILogConsumer> logConsumerFactory)
        {
            typeAlias.CheckNotNullOrWhitespace(nameof(typeAlias));
            logConsumerFactory.CheckNotNull(nameof(logConsumerFactory));

            AliasFactoryMap[typeAlias.ToLower()] = logConsumerFactory;
        }

        public static ILogConsumer Resolve(string typeNameOrAlias)
        {
            typeNameOrAlias.CheckNotNullOrWhitespace(nameof(typeNameOrAlias));

            return AliasFactoryMap.TryGetValue(typeNameOrAlias, out Func<ILogConsumer> factory)
                ? factory()
                : ActivatorEx.CreateInstance<ILogConsumer>(typeNameOrAlias);
        }
    }
}
{'fraction_non_alphanumeric': 0.08620207108872097, 'fraction_numerical': 0.002239014833473272, 'mean_word_length': 2.70746887966805, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 32, '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': '7645805', 'n_tokens_mistral': 926, 'n_tokens_neox': 895, 'n_words': 187}