Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

77 wiersze
2.3 KiB

  1. using DotNetCore.CAP.RedisStreams;
  2. using Microsoft.AspNetCore.Builder;
  3. using Microsoft.AspNetCore.Hosting;
  4. using Microsoft.AspNetCore.HttpsPolicy;
  5. using Microsoft.AspNetCore.Mvc;
  6. using Microsoft.EntityFrameworkCore;
  7. using Microsoft.Extensions.Configuration;
  8. using Microsoft.Extensions.DependencyInjection;
  9. using Microsoft.Extensions.Hosting;
  10. using Microsoft.Extensions.Logging;
  11. using Microsoft.OpenApi.Models;
  12. using Sample.Redis.SqlServer;
  13. using System;
  14. using System.Collections.Generic;
  15. using System.Linq;
  16. using System.Threading.Tasks;
  17. namespace Samples.Redis.SqlServer
  18. {
  19. public class Startup
  20. {
  21. public Startup(IConfiguration configuration)
  22. {
  23. Configuration = configuration;
  24. }
  25. public IConfiguration Configuration { get; }
  26. // This method gets called by the runtime. Use this method to add services to the container.
  27. public void ConfigureServices(IServiceCollection services)
  28. {
  29. services.AddControllers();
  30. services.AddSwaggerGen(c =>
  31. {
  32. c.SwaggerDoc("v1", new OpenApiInfo { Title = "Samples.Redis.SqlServer", Version = "v1" });
  33. });
  34. services.AddDbContext<AppDbContext>(options =>
  35. {
  36. options.UseSqlServer("data source=.;initial catalog=cap;integrated security=true");
  37. });
  38. services.AddCap(options =>
  39. {
  40. options.UseRedis();
  41. options.UseEntityFramework<AppDbContext>();
  42. options.DefaultGroupName = "Samples.Redis.SqlServer";
  43. });
  44. }
  45. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  46. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  47. {
  48. if (env.IsDevelopment())
  49. {
  50. app.UseDeveloperExceptionPage();
  51. app.UseSwagger();
  52. app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Samples.Redis.SqlServer v1"));
  53. }
  54. app.UseHttpsRedirection();
  55. app.UseRouting();
  56. app.UseAuthorization();
  57. app.UseEndpoints(endpoints =>
  58. {
  59. endpoints.MapControllers();
  60. });
  61. }
  62. }
  63. }