<commit_before>﻿using System;
using System.Collections.Generic;
using System.Reflection;
using Com.AimUI.TagCore.Tags;
using Com.AimUI.TagCore.Exceptions;

namespace Com.AimUI.TagCore
{
    public delegate ITag<T> TagConstructorDelegate<T>(string tagName) where T : TagContext;
    public class TagLib<T> where T : TagContext
    {
        public static IParser<T> tagParser { get; private set; }

        private Assembly libAssembly;
        private string low_nameSpace;

        public string nameSpace { get; private set; }

        public bool isCache { get; private set; }

        private static ITagCache<T> tagCache;

        private TagConstructorDelegate<T> tagConstructor;

        public TagLib(string _nameSpace, bool _isCache, TagConstructorDelegate<T> _tagConstructor = null)
        {
            nameSpace = _nameSpace;
            low_nameSpace = _nameSpace.ToLower();
            isCache = _isCache;
            if (tagConstructor != null) tagConstructor = _tagConstructor;
        }

        public void SetTagConstruct(TagConstructorDelegate<T> _tagConstruct)
        {
            tagConstructor = _tagConstruct;
        }

        private ITag<T> GetTagInstanceFromAssembly(string nameSpace, string tagName)
        {
            if (libAssembly == null)
            {
                libAssembly = Assembly.Load("Com.AimUI.Tag." + nameSpace);
            }

            Type tagType = libAssembly.GetType("Com.AimUI.Tag." + nameSpace + "." + tagName, false, true);

            if (tagType == null)
            {
                return null;
            }
            return (ITag<T>)Activator.CreateInstance(tagType);
        }

        public ITag<T> GetTagInstance(string tagName, bool isCreateNew = true)
        {
            ITag<T> obj;
            if (isCache)
            {<commit_msg>no message<commit_after>﻿using System;
using System.Collections.Generic;
using System.Reflection;
using Com.AimUI.TagCore.Tags;
using Com.AimUI.TagCore.Exceptions;

namespace Com.AimUI.TagCore
{
    public delegate ITag<T> TagConstructorDelegate<T>(string tagName) where T : TagContext;
    public class TagLib<T> where T : TagContext
    {
        public static IParser<T> tagParser { get; private set; }

        private Assembly libAssembly;
        private string low_nameSpace;

        public string nameSpace { get; private set; }

        public bool isCache { get; private set; }

        private static ITagCache<T> tagCache;

        private TagConstructorDelegate<T> tagConstructor;

        public TagLib(string _nameSpace, bool _isCache, TagConstructorDelegate<T> _tagConstructor = null)
        {
            nameSpace = _nameSpace;
            low_nameSpace = _nameSpace.ToLower();
            isCache = _isCache;
            if (tagConstructor != null) tagConstructor = _tagConstructor;
        }

        public void SetTagConstruct(TagConstructorDelegate<T> _tagConstruct)
        {
            tagConstructor = _tagConstruct;
        }

        private ITag<T> GetTagInstanceFromAssembly(string nameSpace, string tagName)
        {
            if (libAssembly == null)
            {
                libAssembly = Assembly.Load("Com.AimUI.Tag." + nameSpace);
            }

            Type tagType = libAssembly.GetType("Com.AimUI.Tag." + nameSpace + "." + tagName, false, true);

            if (tagType == null)
            {
                return null;
            }
            return Activator.CreateInstance(tagType) as ITag<T>;
        }

        public ITag<T> GetTagInstance(string tagName, bool isCreateNew = true)
        {
            ITag<T> obj;
            if (isCache)
            {
{'fraction_non_alphanumeric': 0.08573784006595218, 'fraction_numerical': 0.0, 'mean_word_length': 2.1707317073170733, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '1331450', 'n_tokens_mistral': 1006, 'n_tokens_neox': 977, 'n_words': 243}