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.

Startup.cs 1.1 KiB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Microsoft.AspNetCore.Builder;
  2. using Microsoft.Extensions.Configuration;
  3. using Microsoft.Extensions.DependencyInjection;
  4. using MongoDB.Driver;
  5. namespace Sample.RabbitMQ.MongoDB
  6. {
  7. public class Startup
  8. {
  9. public Startup(IConfiguration configuration)
  10. {
  11. Configuration = configuration;
  12. }
  13. public IConfiguration Configuration { get; }
  14. public void ConfigureServices(IServiceCollection services)
  15. {
  16. services.AddSingleton<IMongoClient>(new MongoClient(Configuration.GetConnectionString("MongoDB")));
  17. services.AddCap(x =>
  18. {
  19. x.UseMongoDB(Configuration.GetConnectionString("MongoDB"));
  20. x.UseRabbitMQ("192.168.2.120");
  21. x.UseDashboard();
  22. });
  23. services.AddControllers();
  24. }
  25. public void Configure(IApplicationBuilder app)
  26. {
  27. app.UseRouting();
  28. app.UseEndpoints(endpoints =>
  29. {
  30. endpoints.MapControllers();
  31. });
  32. }
  33. }
  34. }