public static IBusPicoServiceBuilder UseAspNetCoreDI(this IDependencyInjectionPicoServiceBuilder builder, Action <IServiceCollection> registrations)
        {
            var registrationStep = new PicoServiceConfigurationStep(registrations);
            var aspNetCoreDependencyResolverBuilningStep = CreateAspNetCoreDependencyResolverBuilningStep();

            builder.Configurator.AddStep(registrationStep);
            builder.Configurator.AddStep(aspNetCoreDependencyResolverBuilningStep);
            return((IBusPicoServiceBuilder)builder);
        }
Esempio n. 2
0
        private static void AddCorsStep(this IPicoServiceConfigurator configurator, string policyName, Action <CorsOptions> options)
        {
            Action <IServiceCollection>  configureServicesAction = services => services.AddCors(options);
            Action <IApplicationBuilder> configureAction         = app => app.UseCors(policyName);

            var corsStep = new PicoServiceConfigurationStep(configureServicesAction, configureAction);

            configurator.AddStep(corsStep);
        }
        public static IPicoServiceBuilder UseServiceBus(this IBusPicoServiceBuilder builder, ServiceBusConfiguration configuration, Action <ISubscribeBus> registrations)
        {
            Action <IServiceCollection> configureServicesAction = services =>
            {
                services.AddSingleton(typeof(ServiceBusConfiguration), configuration);
                services.AddTransient <IPublishBus, ServiceBus>();
                services.AddTransient <ISubscribeBus, ServiceBus>();
            };

            Action <IApplicationBuilder> configureAction = app =>
            {
                var subscribeBus = app.ApplicationServices.GetService <ISubscribeBus>();
                registrations(subscribeBus);
            };

            var busStep = new PicoServiceConfigurationStep(configureServicesAction, configureAction);

            builder.Configurator.AddStep(busStep);
            return(builder);
        }