示例#1
0
        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));
        }
示例#2
0
 public DependencyLegalityChecker(ApplicationLayerConfiguration configuration)
 {
     _configuration = configuration;
 }