public static void RegistrationByConvention(this Container container, BehaviorConfiguration configuration, Action<IConventionBuilderSyntax<Lifestyle, Container>> convention) { if (configuration == null) { configuration = BehaviorConfiguration.Default; } var logger = new DiagnosticLogger(configuration); var serviceMappingTracker = new ServiceMappingTracker(logger); var implementationFilter = new ImplementationFilter(); var adapter = new SimpleInjectorContainerAdapter(container, serviceMappingTracker, implementationFilter); var configServiceFilter = ((IBehaviorConfiguration)configuration).GetServiceFilter(); var asmSelector = new AssemblySelector(); var serviceExtractor = new ServiceExtractor(); var containerDecorator = new ContainerLogger<Lifestyle>(adapter, logger); var serviceFilterAggregator = new ServiceFilterAggregator(new IServiceFilter[] { configServiceFilter, implementationFilter, serviceExtractor, serviceMappingTracker }); using (var builder = new ConventionBuilder<Lifestyle>(containerDecorator, asmSelector, serviceFilterAggregator, serviceExtractor)) { var importer = new ConventionBuilderSyntaxDecorator<Lifestyle, Container>(builder, container, implementationFilter, asmSelector); convention(importer); } }
//, IEnumerable<Type> serviceExclusions = null) public static void RegistrationByConvention(this UnityContainer container, BehaviorConfiguration configuration, Action<IConventionBuilder<LifetimeManager>, IImplementationFilter> convention) { if (configuration == null) { configuration = BehaviorConfiguration.Default; } var logger = new DiagnosticLogger(configuration); var serviceMappingTracker = new ServiceMappingTracker(logger); var implementationFilter = new ImplementationFilter(); var configServiceFilter = ((IBehaviorConfiguration)configuration).GetServiceFilter(); var adapter = new UnityContainerAdapter(container, serviceMappingTracker); var asmSelector = new AssemblySelector(); var serviceExtractor = new ServiceExtractor(); var serviceFilterAggregator = new ServiceFilterAggregator(new IServiceFilter[] { configServiceFilter, implementationFilter, serviceExtractor, serviceMappingTracker }); using (var builder = new ConventionBuilder<LifetimeManager>(adapter, asmSelector, serviceFilterAggregator, serviceExtractor)) { convention(builder, implementationFilter); } }
public void ExcludeServices_ServiceTypesToExcludeNullValueGiven_ShouldThrowArgumentNullException() { var behaviorConfiguration = new BehaviorConfiguration(); behaviorConfiguration.ExcludeServices((Type[])null); }
public void ExcludeServices_FilterNullValueGiven_ShouldThrowArgumentNullException() { var behaviorConfiguration = new BehaviorConfiguration(); behaviorConfiguration.ExcludeServices((Func<Type, bool>)null); }
public static void RegistrationByConvention(this UnityContainer container, BehaviorConfiguration configuration, Action<IConventionBuilder<LifetimeManager>> convention) { RegistrationByConvention(container, configuration, (builder, tracker) => convention(builder)); }