Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

50 rader
1.8 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. {
  26. x.UseEntityFramework<AppDbContext>();
  27. //x.UseSqlServer("Server=DESKTOP-M9R8T31;Initial Catalog=Test;User Id=sa;Password=P@ssw0rd;MultipleActiveResultSets=True");
  28. x.UseRabbitMQ(o => { o.HostName = "192.168.2.206"; o.UserName = "admin"; o.Password = "123123"; });
  29. });
  30. // Add framework services.
  31. services.AddMvc();
  32. }
  33. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  34. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  35. {
  36. loggerFactory.AddConsole(Configuration.GetSection("Logging"));
  37. loggerFactory.AddDebug();
  38. app.UseMvc();
  39. app.UseCap();
  40. }
  41. }
  42. }