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

ConfigurationParametersInspector

Check for a node 'parameters' within the component configuration. For each child it, a ParameterModel is created and added to ComponentModel's Parameters collection
using Castle.Core; using Castle.Core.Configuration; using Castle.Core.Internal; using Castle.MicroKernel.Util; using System; using System.Collections.Generic; namespace Castle.MicroKernel.ModelBuilder.Inspectors { [Serializable] public class ConfigurationParametersInspector : IContributeComponentModelConstruction { public virtual void ProcessModel(IKernel kernel, ComponentModel model) { if (model.Configuration != null) { IConfiguration configuration = model.Configuration.Children["parameters"]; if (configuration != null) { foreach (IConfiguration child in configuration.Children) { string name = child.Name; string value = child.Value; if (value == null && child.Children.Count != 0) { IConfiguration configNode = child.Children[0]; model.Parameters.Add(name, configNode); } else model.Parameters.Add(name, value); } InspectCollections(model); } } } private void AddAnyServiceOverrides(ComponentModel model, IConfiguration config, ParameterModel parameter) { foreach (IConfiguration child in config.Children) { if (child.Children.Count > 0) AddAnyServiceOverrides(model, child, parameter); string text = ReferenceExpressionUtil.ExtractComponentName(child.Value); if (text != null) model.Dependencies.Add(new ComponentDependencyModel(text)); } } private void InspectCollections(ComponentModel model) { foreach (ParameterModel item in (IEnumerable<ParameterModel>)model.Parameters) { if (item.ConfigValue != null && (IsArray(item) || IsList(item))) AddAnyServiceOverrides(model, item.ConfigValue, item); if (ReferenceExpressionUtil.IsReference(item.Value)) model.Dependencies.Add(new DependencyModel(item.Name, null, false)); } } private bool IsArray(ParameterModel parameter) { return parameter.ConfigValue.Name.EqualsText("array"); } private bool IsList(ParameterModel parameter) { return parameter.ConfigValue.Name.EqualsText("list"); } } }