Esempio n. 1
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);
 }
Esempio n. 2
0
        public void PostConfigureServices()
        {
            var services = new ServiceCollection();
            var options  = new BootstrapperCreationOptions();

            options.PostConfigureServices(c => c.Properties.Add("test", "value"));
            var context = new ConfigureServicesContext(null, services, null);

            context.Properties.ShouldBeEmpty();
            options.PostConfigureServices(context);
            context.Properties.ShouldHaveSingleItem().Key.ShouldBe("test");
        }
Esempio n. 3
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);
 }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="startupModuleType"></param>
        /// <param name="services"></param>
        /// <param name="configuration"></param>
        /// <param name="optionsAction"></param>
        protected Bootstrapper(Type startupModuleType, IServiceCollection services, IConfiguration configuration, Action <BootstrapperCreationOptions> optionsAction)
        {
            Services          = services;
            StartupModuleType = startupModuleType;
            Properties        = new Dictionary <string, object>();
            _options          = new BootstrapperCreationOptions(services);
            ModuleLoader      = new ModuleLoader();
            optionsAction(_options);
            var configBuilder = new ConfigurationBuilder();

            if (configuration != null)
            {
                configBuilder.AddConfiguration(configuration);
            }
            _options.ConfigurationActions.ForEach(a => a(configBuilder));
            this.Configuration = configBuilder.Build();
            ConfigureCoreService(services);
            Modules = LoadModules();
            ConfigureServices();
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="options"></param>
 /// <param name="action"></param>
 public static void Configuration(this BootstrapperCreationOptions options, Action <IConfigurationBuilder> action)
 {
     options.ConfigurationActions.Add(action);
 }
Esempio n. 6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="options"></param>
 /// <returns></returns>
 public static BootstrapperCreationOptions UseAspectCore(this BootstrapperCreationOptions options)
 {
     options.UseServiceProviderFactory(new AspectCore.Extensions.DependencyInjection.ServiceContextProviderFactory());
     options.PostConfigureServices(context => DynamicProxy.InterceptorHelper.RegisterConventionalInterceptor(context.Services));
     return(options);
 }
Esempio n. 7
0
 protected override void SetBootstrapperCreationOptions(BootstrapperCreationOptions options) => options.UseAutofac();
Esempio n. 8
0
 protected override void SetBootstrapperCreationOptions(BootstrapperCreationOptions options) => options.UseAspectCore();