예제 #1
0
        private List <ChildKernel> LoadValidators(IKernel kernel, IChildKernelCreator childCreator, List <string> modules)
        {
            // discover dlls which contain validators
            // each validator gets a childkernel for their own separate kernels included in their dlls.

            List <ChildKernel> childKernels = new List <ChildKernel>();

            //Shared names and conventions
            modules.ForEach(m =>
            {
                try
                {
                    var childKernel = childCreator.CreateChildKernelWithModule(kernel, m);

                    if (childKernel == null)
                    {
                        var msg = string.Format(FailedToLoadModule, m);
                        log.Error(string.Format(msg));
                        throw new Exception(msg);
                    }

                    childKernels.Add(childKernel);
                }
                catch (Exception ex)
                {
                    log.Error("An unhandled exception occurred loading validators: {0}", ex);
                    throw ex;
                }
            });
            return(childKernels);
        }
예제 #2
0
        public ValidatorProvider(IKernel kernel, IChildKernelCreator childCreator, IVasaClient vsVasa, IValidatorModuleConfig validatorModuleConfig)
        {
            this._kernel       = Guard.NotNull(kernel, "kernel", log);
            this._childCreator = Guard.NotNull(childCreator, "childKernel", log);
            this._vsVasa       = Guard.NotNull(vsVasa, "vsVasa", log);

            this._validatorModuleConfig = Guard.NotNull(validatorModuleConfig, "validatorModuleConfig", log);

            this.DiscoverValidatorProxies();
            this.DiscoverValidatorInstances();
        }
예제 #3
0
        private List <IValidatorProxy> GetValidatorProxies(IKernel kernel, IChildKernelCreator childCreator, List <string> modules)
        {
            List <IValidatorProxy> validatorProxies = new List <IValidatorProxy>();

            List <ChildKernel> childKernels = LoadValidators(kernel, childCreator, modules);

            log.Debug("There were {childKernelCount} childKernels discovered.", childKernels.Count);

            foreach (var child in childKernels)
            {
                validatorProxies.AddRange(child.GetAll <IValidatorProxy>());
            }

            return(validatorProxies);
        }