public void PreConfigureServices() { var services = new ServiceCollection(); var options = new BootstrapperCreationOptions(); options.PreConfigureServices(c => c.Properties.Add("test", "value")); var context = new ConfigureServicesContext(null, services, null); context.Properties.ShouldBeEmpty(); options.PreConfigureServices(context); context.Properties.ShouldHaveSingleItem().Key.ShouldBe("test"); }
/// <summary> /// /// </summary> /// <param name="options"></param> /// <param name="configurationAction"></param> /// <returns></returns> public static BootstrapperCreationOptions UseAutofac(this BootstrapperCreationOptions options, Action <ContainerBuilder> configurationAction = null) { options.PreConfigureServices(context => { ProxyTargetProvider.Default.Add(new AutofacProxyTargetProvider()); context.Services.AddTransient(typeof(AsyncDeterminationInterceptor <>), typeof(AsyncDeterminationInterceptor <>)); context.Services.AddSingleton <IProxyConventionalAction>(new ProxyConventionalAction()); }); options.UseServiceProviderFactory(new AutofacServiceProviderFactory(configurationAction)); return(options); }
private void ConfigureServices() { var context = new ConfigureServicesContext(this, Services, Configuration); Services.AddSingleton(context); _options.PreConfigureServices(context); Modules.ForEach(m => m.Instance.PreConfigureServices(context)); _options.ConfigureServices(context); Modules.ForEach(m => m.Instance.ConfigureServices(context)); _options.PostConfigureServices(context); Modules.ForEach(m => m.Instance.PostConfigureServices(context)); }
/// <summary> /// /// </summary> /// <param name="options"></param> /// <returns></returns> public static BootstrapperCreationOptions UseAspectCore(this BootstrapperCreationOptions options) { options.PreConfigureServices(context => { ProxyTargetProvider.Default.Add(new AspectCoreProxyTargetProvider()); context.Services.AddSingleton <IProxyConventionalAction>(new ProxyConventionalAction()) .AddSingleton <IAdditionalInterceptorSelector, ConfigureAdditionalInterceptorSelector>() .ConfigureDynamicProxy(c => c.ValidationHandlers.Add(new ConfigureAdditionalAspectValidationHandler(c))); }); options.ConfigureServices(context => context.Services.ReplaceSingleton <IPropertyInjectorFactory, DependencyInjection.PropertyInjectorFactory>() .AddScoped <IServiceResolveCallback, DependencyInjection.PropertyInjectorCallback>().AddTransient(typeof(AspectCoreInterceptorAdapter <>))); options.UseServiceProviderFactory(new AspectCore.Extensions.DependencyInjection.ServiceContextProviderFactory()); return(options); }
private void ConfigureServices() { var context = new ConfigureServicesContext(this, Services, Configuration); Services.AddSingleton(context); Modules.ForEach(m => m.Instance.PreConfigureServices(context)); _options.PreConfigureServices(context); Modules.ForEach(m => { if (m.Instance is ScorpioModule module && !module.SkipAutoServiceRegistration) { Services.RegisterAssemblyByConvention(m.Type.Assembly); } m.Instance.ConfigureServices(context); }); _options.ConfigureServices(context); Modules.ForEach(m => m.Instance.PostConfigureServices(context)); _options.PostConfigureServices(context); }