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

ListConverter

using Castle.Core.Configuration; using System; using System.Collections; using System.Collections.Generic; namespace Castle.MicroKernel.SubSystems.Conversion { [Serializable] public class ListConverter : AbstractTypeConverter { public override bool CanHandleType(Type type) { if (!(type == typeof(IList))) return type == typeof(ArrayList); return true; } public override object PerformConversion(string value, Type targetType) { throw new NotImplementedException(); } public override object PerformConversion(IConfiguration configuration, Type targetType) { List<object> list = new List<object>(); Type convertToType = GetConvertToType(configuration); foreach (IConfiguration child in configuration.Children) { list.Add(base.Context.Composition.PerformConversion(child.Value, convertToType)); } return list; } private Type GetConvertToType(IConfiguration configuration) { string text = configuration.Attributes["type"]; Type result = typeof(string); if (text != null) result = base.Context.Composition.PerformConversion<Type>(text); return result; } } }