MixinInspector
using Castle.Core;
using Castle.Core.Configuration;
using Castle.MicroKernel.Proxy;
using Castle.MicroKernel.Util;
using System;
using System.Collections.Generic;
namespace Castle.MicroKernel.ModelBuilder.Inspectors
{
    [Serializable]
    public class MixinInspector : IContributeComponentModelConstruction
    {
        public void ProcessModel(IKernel kernel, ComponentModel model)
        {
            if (model.Configuration != null) {
                IConfiguration configuration = model.Configuration.Children["mixins"];
                if (configuration != null) {
                    List<ComponentReference<object>> list = new List<ComponentReference<object>>();
                    foreach (IConfiguration child in configuration.Children) {
                        string value = child.Value;
                        string text = ReferenceExpressionUtil.ExtractComponentName(value);
                        if (text == null)
                            throw new Exception($"""{value}""");
                        list.Add(new ComponentReference<object>(text));
                    }
                    if (list.Count != 0) {
                        ProxyOptions object = model.ObtainProxyOptions(true);
                        list.ForEach(object.AddMixinReference);
                    }
                }
            }
        }
    }
}