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());

 

posted @ 2017-03-12 10:51  蓝平凡  阅读(222)  评论(0编辑  收藏  举报