public static ContainerBuilder RegisterApplicationLayer( this ContainerBuilder containerBuilder, Assembly assembly, Action <ApplicationLayerConfiguration> configurationAction) { var configuration = new ApplicationLayerConfiguration(); configurationAction(configuration); var legalityChecker = new DependencyLegalityChecker(configuration); containerBuilder .RegisterInstance(legalityChecker) .AsSelf(); containerBuilder.RegisterBuildCallback(context => { var checker = context.Resolve <DependencyLegalityChecker>(); foreach (var registration in context.ComponentRegistry.Registrations) { var serviceType = registration.Activator.LimitType; checker.ThrowIfIllegalDependency(serviceType); } }); return(RegisterApplicationLayer(containerBuilder, assembly)); }
public DependencyLegalityChecker(ApplicationLayerConfiguration configuration) { _configuration = configuration; }