<PackageReference Include="Castle.Windsor" Version="6.0.0" />

DefaultHandlerFactory

using Castle.Core; using Castle.Core.Internal; using Castle.MicroKernel.ModelBuilder; using System; using System.Collections.Generic; namespace Castle.MicroKernel.Handlers { [Serializable] public class DefaultHandlerFactory : IHandlerFactory { private readonly IKernelInternal kernel; public DefaultHandlerFactory(IKernelInternal kernel) { this.kernel = kernel; } public virtual IHandler Create(ComponentModel model) { IHandler handler = CreateHandler(model); handler.Init(kernel); return handler; } private IHandler CreateHandler(ComponentModel model) { if (model.RequiresGenericArguments) { IGenericImplementationMatchingStrategy implementationMatchingStrategy = GenericImplementationMatchingStrategy(model); IGenericServiceStrategy serviceStrategy = GenericServiceStrategy(model); return new DefaultGenericHandler(model, implementationMatchingStrategy, serviceStrategy); } ComponentModelDescriptorUtil.RemoveMetaDescriptors(model); ICollection<IResolveExtension> collection = model.ResolveExtensions(false); ICollection<IReleaseExtension> collection2 = model.ReleaseExtensions(false); if (collection2 == null && collection == null) return new DefaultHandler(model); return new ExtendedHandler(model, collection, collection2); } private IGenericImplementationMatchingStrategy GenericImplementationMatchingStrategy(ComponentModel model) { return (IGenericImplementationMatchingStrategy)model.ExtendedProperties[Constants.GenericImplementationMatchingStrategy]; } private IGenericServiceStrategy GenericServiceStrategy(ComponentModel model) { return (IGenericServiceStrategy)model.ExtendedProperties[Constants.GenericServiceStrategy]; } } }