50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
|
|
using System;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Linq;
|
|||
|
|
using EntityFrameworkCore.BootKit;
|
|||
|
|
using Microsoft.AspNetCore.Builder;
|
|||
|
|
using Microsoft.AspNetCore.Hosting;
|
|||
|
|
using Microsoft.AspNetCore.Http;
|
|||
|
|
using Microsoft.Extensions.Configuration;
|
|||
|
|
using Microsoft.Extensions.DependencyInjection;
|
|||
|
|
using Newtonsoft.Json.Serialization;
|
|||
|
|
|
|||
|
|
namespace BotSharp.WebHost
|
|||
|
|
{
|
|||
|
|
public partial class Startup
|
|||
|
|
{
|
|||
|
|
public Startup(IConfiguration configuration)
|
|||
|
|
{
|
|||
|
|
Configuration = configuration;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public IConfiguration Configuration { get; }
|
|||
|
|
|
|||
|
|
public void ConfigureServices(IServiceCollection services)
|
|||
|
|
{
|
|||
|
|
services.AddMvc(options =>
|
|||
|
|
{
|
|||
|
|
options.RespectBrowserAcceptHeader = true;
|
|||
|
|
}).AddJsonOptions(options =>
|
|||
|
|
{
|
|||
|
|
options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
|
|||
|
|
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
|
|||
|
|
{
|
|||
|
|
if (env.IsDevelopment())
|
|||
|
|
{
|
|||
|
|
app.UseDeveloperExceptionPage();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
app.UseMvc();
|
|||
|
|
|
|||
|
|
Database.Configuration = Configuration;
|
|||
|
|
Database.ContentRootPath = env.ContentRootPath;
|
|||
|
|
Database.Assemblies = new String[] { "BotSharp.Core" };
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|