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

namespace angeldnd.dap {
    public static class Factory {
        private static readonly Dictionary<string, Type> _Types = new Dictionary<string, Type>();

        public static bool Register<T>(string type) where T : class, IObject {
            return Register(type, typeof(T));
        }

        public static bool Register(string type, Type newType) {
            Type oldType = GetDapType(type);
            if (oldType != null) {
                if (oldType == newType) {
                    return true;
                } else {
                    Log.Critical("Factory.Register: <{0}> Already Registered: {1} -> {2}",
                                type, oldType.FullName, newType.FullName);
                    return false;
                }
            }
            _Types[type] = newType;
            return true;
        }

        public static Type GetDapType(string type) {
            Type oldType;
            if (_Types.TryGetValue(type, out oldType)) {
                return oldType;
            }
            return null;
        }

        private static T Create<T>(string caller, Type type, params object[] values) {
            if (type != null) {
                try {
                    object obj = Activator.CreateInstance(type, values);
                    if (obj is T) {
                        return (T)obj;
                    } else {
                        Log.Error("Factory.{0}: <{1}> Type Mismatched: {2} -> {3}",
                                caller, typeof(T).FullName, type, obj.GetType().FullName);
                    }
                } catch (Exception e) {
                    Log.Error("Factory.{0}: <{1}> {2} -> {3}",
                                caller, typeof(T).FullName, type, e);
                }
            } else {
                Log.Error("Factory.{0}: <{1}> {2} -> Unknown Type",
                                caller, typeof(T).FullName, type);
            }
            return default(T);
        }

        public static T New<T>(string type, params object[] values) where T : IObject {
            return Create<T>("New", GetDapType(type), values);
        }

        public static T Create<T>(Type type, params object[] values) {
            return Create<T>("Create", type, values);
        }

        public static T Create<T>(params object[] values) {
            return Create<T>(typeof(T), values);
        }
    }
}<commit_msg>better log info in Factory<commit_after>using System;
using System.Collections.Generic;

namespace angeldnd.dap {
    public static class Factory {
        private static readonly Dictionary<string, Type> _Types = new Dictionary<string, Type>();

        public static bool Register<T>(string type) where T : class, IObject {
            return Register(type, typeof(T));
        }

        public static bool Register(string type, Type newType) {
            Type oldType = GetDapType(type);
            if (oldType != null) {
                if (oldType == newType) {
                    return true;
                } else {
                    Log.Critical("Factory.Register: <{0}> Already Registered: {1} -> {2}",
                                type, oldType.FullName, newType.FullName);
                    return false;
                }
            }
            _Types[type] = newType;
            return true;
        }

        public static Type GetDapType(string type, bool isDebug = false) {
            Type oldType;
            if (_Types.TryGetValue(type, out oldType)) {
                return oldType;
            } else {
                Log.ErrorOrDebug(isDebug, "DapType Not Found: {0}", type);
            }
            return null;
        }

        private static T Create<T>(string caller, Type type, params object[] values) {
            if (type != null) {
                try {
                    object obj = Activator.CreateInstance(type, values);
                    if (obj is T) {
                        return (T)obj;
                    } else {
                        Log.Error("Factory.{0}: <{1}> Type Mismatched: {2} -> {3}",
                                caller, typeof(T).FullName, type, obj.GetType().FullName);
                    }
                } catch (Exception e) {
                    Log.Error("Factory.{0}: <{1}> {2} -> {3}",
                                caller, typeof(T).FullName, type, e);
                }
            } else {
                Log.Error("Factory.{0}: <{1}> {2} -> Unknown Type",
                                caller, typeof(T).FullName, type);
            }
            return default(T);
        }

        public static T New<T>(string type, params object[] values) where T : IObject {
            Type dapType = GetDapType(type);
            if (dapType != null) {
                return Create<T>("New", dapType, values);
            }
            return default(T);
        }

        public static T Create<T>(Type type, params object[] values) {
            return Create<T>("Create", type, values);
        }

        public static T Create<T>(params object[] values) {
            return Create<T>(typeof(T), values);
        }
    }
}
{'fraction_non_alphanumeric': 0.11441735457861393, 'fraction_numerical': 0.0055672873872144365, 'mean_word_length': 1.3542702214188884, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 39, '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': '796268', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1313, 'n_words': 368}