private void ApplySettings(ModularServiceSettingsList <TService> settingsList, string text)
        {
            Queue <ServiceCallInfo <TService> > newConstructors = new Queue <ServiceCallInfo <TService> >();

            for (int i = 0; i < settingsList.Count; i++)
            {
                ServiceModuleSettings moduleSettings = settingsList[i];

                if (settingsList[i] == null)
                {
                    try { throw new NullReferenceException($"{nameof(moduleSettings)} at index {i} is null."); }
                    catch (Exception e)
                    {
                        switch (_exceptionHandler.HandleConfigApplyException(e, moduleSettings, i))
                        {
                        case OnExceptionAction.Throw: throw;

                        case OnExceptionAction.Stop: _constructors = newConstructors; return;

                        case OnExceptionAction.Continue: continue;
                        }
                    }
                }
                else if (settingsList[i].Ignore)
                {
                    continue;
                }

                try
                {
                    string assemblyPath = moduleSettings.PathType == PathType.Absolute ?
                                          moduleSettings.DllPath :
                                          Path.Combine(_configuration.GetValue <string>(WebHostDefaults.ContentRootKey), moduleSettings.DllPath);

                    Type moduleType = TypeHelper.LoadModuleTypeFromAssembly(assemblyPath, moduleSettings.FullNameOfType, typeof(IModule <TService>));

                    ServiceCallInfo <TService> callInfo = new ServiceCallInfo <TService>
                    {
                        Constructor = Expression.Lambda <Func <IModule <TService> > >(Expression.New(moduleType)).Compile(),
                        OnConstructorExceptionAction = settingsList[i].OnConstructorExceptionAction,
                        OnInitializeExceptionAction  = settingsList[i].OnInitializeExceptionAction
                    };

                    newConstructors.Enqueue(callInfo);
                }
                catch (Exception e)
                {
                    switch (moduleSettings.OnConfigApplyExceptionAction ?? _exceptionHandler.HandleConfigApplyException(e, moduleSettings, i))
                    {
                    case OnExceptionAction.Throw: throw;

                    case OnExceptionAction.Stop: _constructors = newConstructors; return;

                    case OnExceptionAction.Continue: continue;
                    }
                }
            }

            _constructors = newConstructors;
        }
        public ModularService(TService instance, IServiceModuleContainer <TService> moduleBuilder, IServiceExceptionHandler <TService> exceptionHandler) : this(instance)
        {
            for (int i = 0; i < moduleBuilder.CallInformation.Count; i++)
            {
                ServiceCallInfo <TService> callInfo = moduleBuilder.CallInformation.ElementAt(i);
                IModule <TService>         module   = default;

                try
                {
                    module = callInfo.Constructor();
                }
                catch (Exception e)
                {
                    switch (callInfo?.OnConstructorExceptionAction ?? exceptionHandler.HandleModuleConstructorException(e, instance, i))
                    {
                    case OnExceptionAction.Continue: continue;

                    case OnExceptionAction.Stop: return;

                    case OnExceptionAction.Throw: throw;
                    }
                }

                try
                {
                    module?.Initialize(instance);
                }
                catch (Exception e)
                {
                    switch (callInfo?.OnInitializeExceptionAction ?? exceptionHandler.HandleModuleInitializationException(e, instance, module, i))
                    {
                    case OnExceptionAction.Continue: continue;

                    case OnExceptionAction.Stop: return;

                    case OnExceptionAction.Throw: throw;
                    }
                }
            }
        }