|
1 | 1 | using Api.Configuration;
|
| 2 | +using Api.Extensions; |
| 3 | +using Api.Validation; |
2 | 4 | using Bll.Domain.Entities;
|
3 | 5 | using Bll.Domain.Factories;
|
4 | 6 | using Bll.Domain.Interfaces;
|
| 7 | +using Bll.Domain.Models; |
5 | 8 | using Bll.Domain.Services;
|
| 9 | +using FluentValidation; |
| 10 | +using FluentValidation.AspNetCore; |
| 11 | +using NLog.Web; |
6 | 12 |
|
7 | 13 | var builder = WebApplication.CreateBuilder(args);
|
8 | 14 |
|
9 |
| -builder.Services.AddControllers(); |
| 15 | +builder.Services.AddControllers().AddFluentValidation(fv => |
| 16 | +{ |
| 17 | +fv.RegisterValidatorsFromAssemblyContaining<InputParametersValidator>(); |
| 18 | +}); |
| 19 | + |
| 20 | +#region Logger |
| 21 | +builder.Logging.ClearProviders(); |
| 22 | +builder.Logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); |
| 23 | +builder.Host.UseNLog(); |
| 24 | +#endregion |
10 | 25 | builder.Services.AddEndpointsApiExplorer();
|
11 | 26 | builder.Services.AddSwaggerGen();
|
12 | 27 |
|
13 | 28 | #region servicesDI
|
14 | 29 | builder.Services.AddTransient<ISimulationService, SimulationService>();
|
15 | 30 |
|
16 | 31 | builder.Services.AddScoped<ITimeProvider, TimeProvider>();
|
| 32 | +builder.Services.AddScoped<IFlowProvider, PoissonianFlowProvider>(); |
| 33 | + |
17 | 34 | builder.Services.AddScoped<IResults, Bll.Domain.Entities.Results>();
|
18 | 35 | builder.Services.AddScoped<IResultManager, ResultManager>();
|
19 |
| -builder.Services.AddScoped<IResultManager, ResultManager>(); |
20 |
| -//builder.Services.AddTransient<IBufferManager, StandardBufferManager>(); |
| 36 | + |
21 | 37 | builder.Services.AddTransient<IBufferManagerFactory, BufferManagerFactory>();
|
22 | 38 | builder.Services.AddTransient<IDeviceManager, DeviceManager>();
|
23 | 39 | builder.Services.AddTransient<ISourceManager, SourceManager>();
|
24 |
| -//builder.Services.AddScoped<StandardBufferManager>() |
25 |
| -// .AddScoped<IBufferManager, StandardBufferManager>(s => s.GetRequiredService<StandardBufferManager>()); |
26 | 40 |
|
27 |
| -//builder.Services.AddScoped<IBufferManager>(s => |
28 |
| -// ActivatorUtilities.CreateInstance<StandardBufferManager>(s)); |
| 41 | +builder.Services.AddTransient<IValidator<InputParameters>, InputParametersValidator>(); |
29 | 42 | #endregion
|
30 | 43 |
|
| 44 | +#region Mapper |
31 | 45 | builder.Services.AddMapper();
|
| 46 | +#endregion |
| 47 | + |
| 48 | +#region CORS |
| 49 | +builder.Services.AddCors(opts => |
| 50 | +{ |
| 51 | + opts.AddPolicy(CorsPolicies.AllowRemoteFrontendWithCredentials); |
| 52 | +}); |
| 53 | +#endregion |
| 54 | + |
32 | 55 |
|
33 | 56 | var app = builder.Build();
|
34 | 57 |
|
|
38 | 61 | app.UseSwaggerUI();
|
39 | 62 | }
|
40 | 63 |
|
| 64 | +app.UseCustomExceptionHandler(); |
| 65 | + |
41 | 66 | app.UseHttpsRedirection();
|
42 | 67 |
|
43 | 68 | app.UseAuthorization();
|
|
0 commit comments