/// <summary>The main form_ form closing.</summary> /// <param name="sender">The sender.</param> /// <param name="e">The e.</param> private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (e.Cancel) { return; } if (_settings.ConnectionDefinition != null) { Settings.Default.NammedConnection = _settings.ConnectionDefinition.Name; Settings.Default.Save(); } List <IPlugIn> plugins = new List <IPlugIn>(_services.Plugins.Values); plugins.Reverse(); foreach (IPlugIn plugin in plugins) { plugin.UnloadPlugIn(); } _services.Dispose(); }
public void Configure(IApplicationBuilder app, IHostEnvironment environment, IConfiguration configuration, IApplicationServices applicationServices, IApplicationLifetime applicationLifetime, ILogger <Startup> logger) { var thisAssembly = typeof(Startup).Assembly; var assemblyName = thisAssembly.GetName(); var versionAttribute = thisAssembly.GetCustomAttribute <AssemblyFileVersionAttribute>(); var name = $"{ assemblyName.Name } API v{ versionAttribute.Version }"; var hostName = Dns.GetHostName(); var pathBase = configuration["PathBase"]; applicationLifetime.ApplicationStopping.Register(() => { applicationServices.Dispose(); }); logger.LogInformation("Configuring startup"); configuration["HydraDevOpsServicesBaseUrl"] = hostName + pathBase; app.UseExceptionHandler(o => { o.Run(async context => { var contextFeature = context.Features.Get <IExceptionHandlerFeature>(); if (contextFeature != null) { logger.LogError($"Error: { contextFeature.Error }"); await context.Response.BodyWriter.WriteAsync(ASCIIEncoding.UTF8.GetBytes(contextFeature.Error.Message)); } }); }); app.UsePathBase(pathBase); if (environment.IsDevelopment() || environment.IsStaging()) { app.UseOpenApi(); app.UseSwaggerUi3(c => { c.ServerUrl = pathBase; }); app.UseDeveloperExceptionPage(); } app.UseCors(AllowAll); app.UseHttpsRedirection(); app.UseRouting(); app.UseJwtServiceAuthorization(); app.UseAuthentication(); app.UseAuthorization(); app.UseStaticFiles(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapRazorPages(); }); logger.LogInformation("End configuring startup"); }