You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

52 regels
1.8 KiB

  1. using DotNetCore.CAP.EntityFrameworkCore;
  2. using Microsoft.AspNetCore.Builder;
  3. using Microsoft.AspNetCore.Hosting;
  4. using Microsoft.Extensions.Configuration;
  5. using Microsoft.Extensions.DependencyInjection;
  6. using Microsoft.Extensions.Logging;
  7. namespace Sample.Kafka
  8. {
  9. public class Startup
  10. {
  11. public Startup(IHostingEnvironment env)
  12. {
  13. var builder = new ConfigurationBuilder()
  14. .SetBasePath(env.ContentRootPath)
  15. .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
  16. .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
  17. .AddEnvironmentVariables();
  18. Configuration = builder.Build();
  19. }
  20. public IConfigurationRoot Configuration { get; }
  21. // This method gets called by the runtime. Use this method to add services to the container.
  22. public void ConfigureServices(IServiceCollection services)
  23. {
  24. services.AddDbContext<CapDbContext>();
  25. services.AddCap()
  26. .AddEntityFrameworkStores<CapDbContext>()
  27. .AddRabbitMQ(x =>
  28. {
  29. x.HostName = "localhost";
  30. });
  31. //.AddKafka(x => x.Servers = "");
  32. // Add framework services.
  33. services.AddMvc();
  34. }
  35. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  36. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  37. {
  38. loggerFactory.AddConsole(Configuration.GetSection("Logging"));
  39. loggerFactory.AddDebug();
  40. app.UseMvc();
  41. app.UseCap();
  42. }
  43. }
  44. }