<commit_before>﻿// <copyright file="OptionCollectionFactory.cs" company="<NAME>">
//  Opus
// </copyright>
// <summary>Opus Core</summary>
// <author><NAME></author>
namespace Opus.Core
{
    public static class OptionCollectionFactory
    {
        private readonly static System.Type optionCollectionType = typeof(BaseOptionCollection);

        public static BaseOptionCollection CreateOptionCollection(System.Type requiredOptionCollectionType)
        {
            if (!requiredOptionCollectionType.IsSubclassOf(optionCollectionType))
            {
                throw new Exception(System.String.Format("Type '{0}' does not derive from the base class {1}", requiredOptionCollectionType.ToString(), optionCollectionType.ToString()));
            }

            if (null == requiredOptionCollectionType.GetConstructor(System.Type.EmptyTypes))
            {
                throw new Exception(System.String.Format("Default constructor for type '{0}' does not exist", requiredOptionCollectionType.ToString()));
            }

            BaseOptionCollection optionCollection = System.Activator.CreateInstance(requiredOptionCollectionType) as BaseOptionCollection;
            return optionCollection;
        }

        public static DerivedType CreateOptionCollection<DerivedType>(DependencyNode owningNode) where DerivedType : BaseOptionCollection
        {
            System.Type requiredOptionCollectionType = typeof(DerivedType);
            if (!requiredOptionCollectionType.IsSubclassOf(optionCollectionType))
            {
                throw new Exception(System.String.Format("Type '{0}' does not derive from the base class {1}", requiredOptionCollectionType.ToString(), optionCollectionType.ToString()), false);
            }

            if (null == requiredOptionCollectionType.GetConstructor(new System.Type[] { typeof(DependencyNode) }))
            {
                throw new Exception(System.String.Format("Missing constructor: '{0}(DependencyNode)'", requiredOptionCollectionType.ToString()), false);
            }

            BaseOptionCollection optionCollection = null;
            try
            {
                optionCollection = System.Activator.CreateInstance(requiredOptionCollectionType, new object[] { owningNode }) as BaseOptionCollection;
            }
            catch (System.Reflection.TargetInvocationException ex)
            {
                throw ex.InnerException;
            }

            DerivedType derivedOptionCollection = optionCollection as DerivedType;
            return derivedOptionCollection;
        }
    }
}<commit_msg>More exceptions that don't require a stack trace<commit_after>﻿// <copyright file="OptionCollectionFactory.cs" company="<NAME>">
//  Opus
// </copyright>
// <summary>Opus Core</summary>
// <author><NAME></author>
namespace Opus.Core
{
    public static class OptionCollectionFactory
    {
        private readonly static System.Type optionCollectionType = typeof(BaseOptionCollection);

        public static BaseOptionCollection CreateOptionCollection(System.Type requiredOptionCollectionType)
        {
            if (!requiredOptionCollectionType.IsSubclassOf(optionCollectionType))
            {
                throw new Exception(System.String.Format("Type '{0}' does not derive from the base class {1}", requiredOptionCollectionType.ToString(), optionCollectionType.ToString()),false);
            }

            if (null == requiredOptionCollectionType.GetConstructor(System.Type.EmptyTypes))
            {
                throw new Exception(System.String.Format("Default constructor for type '{0}' does not exist", requiredOptionCollectionType.ToString()), false);
            }

            BaseOptionCollection optionCollection = System.Activator.CreateInstance(requiredOptionCollectionType) as BaseOptionCollection;
            return optionCollection;
        }

        public static DerivedType CreateOptionCollection<DerivedType>(DependencyNode owningNode) where DerivedType : BaseOptionCollection
        {
            System.Type requiredOptionCollectionType = typeof(DerivedType);
            if (!requiredOptionCollectionType.IsSubclassOf(optionCollectionType))
            {
                throw new Exception(System.String.Format("Type '{0}' does not derive from the base class {1}", requiredOptionCollectionType.ToString(), optionCollectionType.ToString()), false);
            }

            if (null == requiredOptionCollectionType.GetConstructor(new System.Type[] { typeof(DependencyNode) }))
            {
                throw new Exception(System.String.Format("Missing constructor: '{0}(DependencyNode)'", requiredOptionCollectionType.ToString()), false);
            }

            BaseOptionCollection optionCollection = null;
            try
            {
                optionCollection = System.Activator.CreateInstance(requiredOptionCollectionType, new object[] { owningNode }) as BaseOptionCollection;
            }
            catch (System.Reflection.TargetInvocationException ex)
            {
                throw ex.InnerException;
            }

            DerivedType derivedOptionCollection = optionCollection as DerivedType;
            return derivedOptionCollection;
        }
    }
}
{'fraction_non_alphanumeric': 0.08601949025487256, 'fraction_numerical': 0.0022488755622188904, 'mean_word_length': 2.6730901582931863, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '923424', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1127, 'n_words': 260}