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

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