// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddControllers(); ConfigureSwagger(services); services.AddAutoMapper(typeof(Startup)); services.AddEventFlow(ef => { var envconfig = EnvironmentConfiguration.Bind(Configuration); services.AddSingleton(envconfig); ef.AddDefaults(typeof(Startup).Assembly); //ef.Configure(cfg => cfg.IsAsynchronousSubscribersEnabled = true); ef.PublishToRabbitMq( RabbitMqConfiguration.With(new Uri(envconfig.RabbitMqConnection), true, 5, envconfig.RabbitExchange)); ef.AddAspNetCore(); //ef.UseHangfireJobScheduler(); ef.UseConsoleLog(); ef.RegisterModule <DomainModule>(); ef.RegisterModule <AccountingReadModelModule>(); ef.RegisterServices(s => { s.Register <ICustomerCommandService, CustomerCommandService>(); s.Register <IAccountCommandService, AccountCommandService>(); s.Register <ITransactionCommandService, TransactionCommandService>(); }); }); }
public static async Task Main(string[] args) { var builder = new HostBuilder() .ConfigureAppConfiguration((host, config) => { config.SetBasePath(Directory.GetCurrentDirectory()); config.AddJsonFile("appsettings.json", true, true); config.AddJsonFile($"appsettings.{host.HostingEnvironment.EnvironmentName}.json", true, true); config.AddEnvironmentVariables(); }) .ConfigureServices( (hostcontext, services) => { var envconfig = EnvironmentConfiguration.Bind(hostcontext.Configuration); services.AddSingleton(envconfig); EventFlowOptions.New .Configure(cfg => cfg.IsAsynchronousSubscribersEnabled = true) .UseServiceCollection(services) .AddAspNetCoreMetadataProviders() .PublishToRabbitMq(RabbitMqConfiguration.With(new Uri($"{envconfig.RabbitMqConnection}"), true, 5, envconfig.RabbitExchange)) .RegisterModule <DomainModule>() // // subscribe services changed // .AddAsynchronousSubscriber <VehicleAggregate, VehicleId, LocationUpdatedEvent, RabbitMqConsumePersistanceService>() .RegisterServices(s => { s.Register <IHostedService, RabbitConsumePersistenceService>(Lifetime.Singleton); s.Register <IHostedService, RabbitMqConsumePersistanceService>(Lifetime.Singleton); }); }) .ConfigureLogging((hostingContext, logging) => { }); await builder.RunConsoleAsync(); }
public IServiceProvider ConfigureServices(IServiceCollection services) { var middlewareConfig = EnvironmentConfiguration.Bind(_configuration); return(EventFlowOptions.New .UseServiceCollection(services.AddSingleton(middlewareConfig)) .RegisterModule <EventSourcingModule>() .CreateServiceProvider()); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { var env = EnvironmentConfiguration.Bind(_configuration); services.ConfigureServices(env, typeof(Startup), new OpenApiInfo { Title = "Movies API", Version = "v1" }); EventFlowOptions.New .UseServiceCollection(services) .AddDefaults(typeof(Startup).Assembly) .AddAspNetCore() .UseConsoleLog() .RegisterModule <DomainModule>() .RegisterModule <MovieReadStoreModule>() .RegisterModule <EventSourcingModule>() .PublishToRabbitMq(RabbitMqConfiguration.With(new Uri(env.RabbitMqConnection))) .CreateServiceProvider(); }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { var env = EnvironmentConfiguration.Bind(_configuration); services.AddAutoMapper() .AddSingleton(env) .AddSwaggerGen(c => c.SwaggerDoc("v1", new Info { Title = "Vehicles API", Version = "v1" })) .AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); return(EventFlowOptions.New .UseServiceCollection(services) .AddAspNetCoreMetadataProviders() .UseConsoleLog() .RegisterModule <DomainModule>() .RegisterModule <VehicleReadStoreModule>() .RegisterModule <EventSourcingModule>() .PublishToRabbitMq(RabbitMqConfiguration.With(new Uri(env.RabbitMqConnection))) .CreateServiceProvider()); }
private static void LoadConfiguration() { EnvironmentConfiguration.Bind(nameof(Configuration), Configuration); EnvironmentConfiguration.Bind(nameof(JwtSettings), JwtSettings); }