Exemple #1
0
        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");
        }
Exemple #2
0
 /// <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);
 }
Exemple #3
0
        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));
        }
Exemple #4
0
 /// <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);
 }
Exemple #5
0
        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);
        }