123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- namespace NoName_CarplateRecognizeCamera_Lab
- {
- public class Startup
- {
- static NLog.Logger mainLogger = NLog.LogManager.LoadConfiguration("nlog.xml").GetLogger("Main");
- public Startup(IConfiguration configuration)
- {
- //Configuration = configuration;
- //using (var context = new ServiceDbContext())
- //{
- // context.Database.Migrate();
- //}
- }
- public IConfiguration Configuration { get; }
- // This method gets called by the runtime. Use this method to add services to the container.
- public void ConfigureServices(IServiceCollection services)
- {
- services.AddCors();
- services.AddMvc();
- //var ttt = Configuration.GetSection("ConnectionStrings");
- // When used with ASP.net core, add these lines to Startup.cs
- //var connectionString = Configuration.GetValue<string>("ConnectionStrings");//.GetConnectionString("ServiceDbContext");
- //services.AddEntityFrameworkNpgsql().AddDbContext<ServiceDbContext>(options => options.UseNpgsql(connectionString));
- //// and add this to appSettings.json
- //// "ConnectionStrings": { "BlogContext": "Server=localhost;Database=blog" }
- //services.AddScoped<DbContext, ServiceDbContext>();
- services.AddMvcCore().AddApiExplorer();
- // Register the Swagger generator, defining 1 or more Swagger documents
- services.AddSwaggerGen(c =>
- {
- //c.SwaggerDoc("v1", new SwaggerDoc { Title = "My API", Version = "v1" });
- });
- }
- // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
- public void Configure(IApplicationBuilder app, IHostingEnvironment env)
- {
- app.UseCors(builder => builder
- .AllowAnyOrigin()
- .AllowAnyMethod()
- .AllowAnyHeader()
- .AllowCredentials());
- //if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- }
- // Enable middleware to serve generated Swagger as a JSON endpoint.
- app.UseSwagger();
- // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
- // specifying the Swagger JSON endpoint.
- app.UseSwaggerUI(c =>
- {
- c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
- c.RoutePrefix = string.Empty;
- });
- app.UseMvc();
- }
- }
- }
|