/// <summary> /// Ctor. /// </summary> /// <param name="model">The model to validate.</param> /// <param name="data">The data needed for validation.</param> protected AbstractValidator(TModel model, TData data) { Logger = AppLogging.CreateLogger(GetType().Name); Model = model; Data = data; }
/// <summary> /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> /// <param name="app">The application builder.</param> /// <param name="env">The environment.</param> /// <param name="applicationLifetime">The application lifetime.</param> public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime) { // set the current directory to the environment content root ... note this is only for AspNet.Core 2.2 ... not need for AspNet.Core 3.0 as issue is fixed. Directory.SetCurrentDirectory(env.ContentRootPath); // set up logging AppLogging.LoggerFactory.AddSerilog(); this.Logger = AppLogging.CreateLogger <Startup>(); // register to flush logs if shutdown called applicationLifetime.ApplicationStopped.Register(Log.CloseAndFlush); // log the environment on startup this.Logger.LogInformation($"Environment is {env.EnvironmentName}"); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); } // initialise health checks app.UseHealthChecks( "/health", new HealthCheckOptions() { Predicate = _ => true }); app.UseHealthChecks( "/healthchecks", options: new HealthCheckOptions() { Predicate = _ => true, ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse }); app.UseHealthChecksUI( setup => { // defaults setup.ApiPath = "/healthchecks-api"; setup.UIPath = "/healthchecks-ui"; setup.WebhookPath = "/healthchecks-webhooks"; setup.ResourcesPath = "/ui/resources"; }); // add middleware app.UseCors("CorsPolicy"); app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseSwagger(); app.UseCorrelationId(); FluentMapper.Initialize(config => { config.AddMap(new PriceMap()); config.AddMap(new PortfolioMap()); config.AddMap(new StaleYieldMap()); config.AddMap(new UnderlyingMap()); config.AddMap(new YieldPointMap()); }); app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "PriceMovement"); }); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { //// To learn more about options for serving an Angular SPA from ASP.NET Core, //// see https://go.microsoft.com/fwlink/?linkid=864501 spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseAngularCliServer(npmScript: "start"); } }); }