首页 > 代码库 > castle windsor学习----ComponentModel construction contributors

castle windsor学习----ComponentModel construction contributors

public class RequireLoggerProperties : IContributeComponentModelConstruction
{
    public void ProcessModel(IKernel kernel, ComponentModel model)
    {
        model.Properties
            .Where(p => p.Dependency.TargetType == typeof(ILogger))
            .All(p => p.Dependency.IsOptional = false);
    }
}
container.Kernel.ComponentModelBuilder.AddContributor(new RequireLoggerProperties());

 

castle windsor学习----ComponentModel construction contributors