| | | 1 | | using Microsoft.Extensions.Configuration; |
| | | 2 | | using Microsoft.Extensions.DependencyInjection; |
| | | 3 | | using Microsoft.AspNetCore.Hosting; |
| | | 4 | | using Microsoft.AspNetCore.Builder; |
| | | 5 | | using SampleDotNetCore2RestStub.Attributes; |
| | | 6 | | using SampleDotNetCore2RestStub.Middleware; |
| | | 7 | | using SampleDotNetCore2RestStub.Repositories; |
| | | 8 | | |
| | | 9 | | namespace SampleDotNetCore2RestStub |
| | | 10 | | { |
| | | 11 | | public class Startup |
| | | 12 | | { |
| | 2 | 13 | | public Startup() |
| | 2 | 14 | | { |
| | 2 | 15 | | var configurationBuilder = new ConfigurationBuilder() |
| | 2 | 16 | | .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) |
| | 2 | 17 | | .AddEnvironmentVariables(); |
| | | 18 | | |
| | 2 | 19 | | Configuration = configurationBuilder.Build(); |
| | 2 | 20 | | } |
| | | 21 | | |
| | 2 | 22 | | public IConfiguration Configuration { get; } |
| | | 23 | | |
| | | 24 | | public void ConfigureServices(IServiceCollection services) |
| | 2 | 25 | | { |
| | 2 | 26 | | services.AddMvc(); |
| | 2 | 27 | | services.Configure<AppConfig>(Configuration); |
| | 2 | 28 | | services.AddScoped<AuthenticationFilterAttribute>(); |
| | | 29 | | |
| | 2 | 30 | | ConfigureRepositories(services); |
| | 2 | 31 | | } |
| | | 32 | | |
| | | 33 | | public virtual void ConfigureRepositories(IServiceCollection services) |
| | 0 | 34 | | { |
| | 0 | 35 | | services.AddSingleton<IPersonRepository, PersonRepository>(); |
| | 0 | 36 | | } |
| | | 37 | | |
| | | 38 | | public void Configure(IApplicationBuilder app, IHostingEnvironment env) |
| | 2 | 39 | | { |
| | 2 | 40 | | app.UseMiddleware<HttpExceptionMiddleware>(); |
| | 2 | 41 | | app.UseMvc(); |
| | 2 | 42 | | } |
| | | 43 | | } |
| | | 44 | | } |