Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Luticate2.Utils.Controllers;
  2. using Microsoft.AspNetCore.Builder;
  3. using Microsoft.AspNetCore.Hosting;
  4. using Microsoft.EntityFrameworkCore;
  5. using Microsoft.Extensions.Configuration;
  6. using Microsoft.Extensions.DependencyInjection;
  7. using Microsoft.Extensions.Logging;
  8. using TestUtils.DataAccess;
  9. using WebApiUtils.Business;
  10. namespace WebApiUtils
  11. {
  12. public class Startup
  13. {
  14. public Startup(IHostingEnvironment env)
  15. {
  16. var builder = new ConfigurationBuilder()
  17. .SetBasePath(env.ContentRootPath)
  18. .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
  19. .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
  20. if (env.IsEnvironment("Development"))
  21. {
  22. // This will push telemetry data through Application Insights pipeline faster, allowing you to view results immediately.
  23. builder.AddApplicationInsightsSettings(developerMode: true);
  24. }
  25. builder.AddEnvironmentVariables();
  26. Configuration = builder.Build();
  27. }
  28. public IConfigurationRoot Configuration { get; }
  29. // This method gets called by the runtime. Use this method to add services to the container
  30. public void ConfigureServices(IServiceCollection services)
  31. {
  32. // Add framework services.
  33. services.AddApplicationInsightsTelemetry(Configuration);
  34. services.AddLuticateUtils(options => options.Version = "dev");
  35. services.AddSingleton<PkGuidBusiness>();
  36. services.AddSingleton<LuUtilsPkGuidDataAccess>();
  37. services.AddDbContext<LuUtilsDbContext>(options =>
  38. {
  39. options.UseNpgsql(Configuration.GetConnectionString("default"));
  40. options.UseInternalServiceProvider(new ServiceCollection()
  41. .AddEntityFrameworkNpgsqlLuticate()
  42. .AddEntityFrameworkNpgsql()
  43. .BuildServiceProvider());
  44. }, ServiceLifetime.Transient);
  45. services.AddMvc()
  46. .AddLuticateUtils();
  47. }
  48. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
  49. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  50. {
  51. loggerFactory.AddConsole(Configuration.GetSection("Logging"));
  52. loggerFactory.AddDebug();
  53. app.UseApplicationInsightsRequestTelemetry();
  54. app.UseApplicationInsightsExceptionTelemetry();
  55. app.UseLuticateUtils();
  56. app.UseMvc();
  57. }
  58. }
  59. }