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.
 
 
 

49 rivejä
1.7 KiB

  1. using Microsoft.AspNetCore.Builder;
  2. using Microsoft.AspNetCore.Hosting;
  3. using Microsoft.Extensions.Configuration;
  4. using Microsoft.Extensions.DependencyInjection;
  5. using Microsoft.Extensions.Logging;
  6. namespace Sample.Kafka
  7. {
  8. public class Startup
  9. {
  10. public Startup(IHostingEnvironment env)
  11. {
  12. var builder = new ConfigurationBuilder()
  13. .SetBasePath(env.ContentRootPath)
  14. .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
  15. .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
  16. .AddEnvironmentVariables();
  17. Configuration = builder.Build();
  18. }
  19. public IConfigurationRoot Configuration { get; }
  20. // This method gets called by the runtime. Use this method to add services to the container.
  21. public void ConfigureServices(IServiceCollection services)
  22. {
  23. services.AddDbContext<AppDbContext>();
  24. services.AddCap(x=> {
  25. x.UseEntityFramework<AppDbContext>();
  26. x.UseSqlServer("Server=DESKTOP-M9R8T31;Initial Catalog=Test;User Id=sa;Password=P@ssw0rd;MultipleActiveResultSets=True");
  27. x.UseRabbitMQ("localhost");
  28. });
  29. // Add framework services.
  30. services.AddMvc();
  31. }
  32. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  33. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  34. {
  35. loggerFactory.AddConsole(Configuration.GetSection("Logging"));
  36. loggerFactory.AddDebug();
  37. app.UseMvc();
  38. app.UseCap();
  39. }
  40. }
  41. }