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());
时间: 2024-11-04 09:27:48