<PackageReference Include="Castle.Windsor" Version="5.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 ((object)model.Configuration != null) { IConfiguration val = model.Configuration.get_Children().get_Item("parameters"); if (val != null) { foreach (IConfiguration item in (List<IConfiguration>)val.get_Children()) { string name = item.get_Name(); string value = item.get_Value(); if (value == null && ((List<IConfiguration>)item.get_Children()).Count != 0) { IConfiguration configNode = ((List<IConfiguration>)item.get_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 item in (List<IConfiguration>)config.get_Children()) { if (((List<IConfiguration>)item.get_Children()).Count > 0) AddAnyServiceOverrides(model, item, parameter); string text = ReferenceExpressionUtil.ExtractComponentName(item.get_Value()); if (text != null) model.Dependencies.Add(new ComponentDependencyModel(text)); } } private void InspectCollections(ComponentModel model) { foreach (ParameterModel item in (IEnumerable<ParameterModel>)model.Parameters) { if ((object)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.get_Name().EqualsText("array"); } private bool IsList(ParameterModel parameter) { return parameter.ConfigValue.get_Name().EqualsText("list"); } } }