Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit d7ad2cc

Browse files
committed
Refactoring
1 parent beff1b7 commit d7ad2cc

File tree

3 files changed

+83
-84
lines changed

3 files changed

+83
-84
lines changed

src/NET6CustomLibrary/Extensions/DependencyInjection.cs

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public static IServiceCollection AddDateTimeOnlyAttributes(this IServiceCollecti
9999
}
100100
#endregion
101101

102-
#region "DB Context"
102+
#region "DB CONTEXT EFCORE"
103103
[Obsolete("This method will be deprecated in future releases.", false)]
104104
public static IServiceCollection AddDbContextGenericsMethods<TDbContext>(this IServiceCollection services) where TDbContext : DbContext
105105
{
@@ -322,95 +322,95 @@ public static IEndpointRouteBuilder AddDatabaseHealthChecks(this IEndpointRouteB
322322
}
323323
#endregion
324324

325-
#region "HEALTH CHECKS WITH UI"
326-
public static IServiceCollection AddHealthChecksSQLite<TDbContext>(this IServiceCollection services, string webAddressGroup, string webAddressTitle, string sqliteConnString) where TDbContext : DbContext
327-
{
328-
services.AddHealthChecks()
329-
.AddDbContextCheck<TDbContext>(name: "Application DB Context", failureStatus: HealthStatus.Degraded)
330-
.AddUrlGroup(new Uri(webAddressGroup), name: webAddressTitle, failureStatus: HealthStatus.Degraded)
331-
.AddSqlite(sqliteConnString);
332-
333-
services.AddHealthChecksUI(setupSettings: setup =>
334-
{
335-
setup.AddHealthCheckEndpoint("Health Check", $"/healthz");
336-
})
337-
.AddInMemoryStorage();
338-
339-
return services;
340-
}
325+
//#region "HEALTH CHECKS WITH UI"
326+
//public static IServiceCollection AddHealthChecksSQLite<TDbContext>(this IServiceCollection services, string webAddressGroup, string webAddressTitle, string sqliteConnString) where TDbContext : DbContext
327+
//{
328+
// services.AddHealthChecks()
329+
// .AddDbContextCheck<TDbContext>(name: "Application DB Context", failureStatus: HealthStatus.Degraded)
330+
// .AddUrlGroup(new Uri(webAddressGroup), name: webAddressTitle, failureStatus: HealthStatus.Degraded)
331+
// .AddSqlite(sqliteConnString);
341332

342-
public static IServiceCollection AddHealthChecksSQLServer<TDbContext>(this IServiceCollection services, string webAddressGroup, string webAddressTitle, string sqliteConnString) where TDbContext : DbContext
343-
{
344-
services.AddHealthChecks()
345-
.AddDbContextCheck<TDbContext>(name: "Application DB Context", failureStatus: HealthStatus.Degraded)
346-
.AddUrlGroup(new Uri(webAddressGroup), name: webAddressTitle, failureStatus: HealthStatus.Degraded)
347-
.AddSqlServer(sqliteConnString);
333+
// services.AddHealthChecksUI(setupSettings: setup =>
334+
// {
335+
// setup.AddHealthCheckEndpoint("Health Check", $"/healthz");
336+
// })
337+
// .AddInMemoryStorage();
348338

349-
services.AddHealthChecksUI(setupSettings: setup =>
350-
{
351-
setup.AddHealthCheckEndpoint("Health Check", $"/healthz");
352-
})
353-
.AddInMemoryStorage();
339+
// return services;
340+
//}
354341

355-
return services;
356-
}
342+
//public static IServiceCollection AddHealthChecksSQLServer<TDbContext>(this IServiceCollection services, string webAddressGroup, string webAddressTitle, string sqliteConnString) where TDbContext : DbContext
343+
//{
344+
// services.AddHealthChecks()
345+
// .AddDbContextCheck<TDbContext>(name: "Application DB Context", failureStatus: HealthStatus.Degraded)
346+
// .AddUrlGroup(new Uri(webAddressGroup), name: webAddressTitle, failureStatus: HealthStatus.Degraded)
347+
// .AddSqlServer(sqliteConnString);
357348

358-
public static IServiceCollection AddHealthChecksMySQL<TDbContext>(this IServiceCollection services, string webAddressGroup, string webAddressTitle, string sqliteConnString) where TDbContext : DbContext
359-
{
360-
services.AddHealthChecks()
361-
.AddDbContextCheck<TDbContext>(name: "Application DB Context", failureStatus: HealthStatus.Degraded)
362-
.AddUrlGroup(new Uri(webAddressGroup), name: webAddressTitle, failureStatus: HealthStatus.Degraded)
363-
.AddMySql(sqliteConnString);
349+
// services.AddHealthChecksUI(setupSettings: setup =>
350+
// {
351+
// setup.AddHealthCheckEndpoint("Health Check", $"/healthz");
352+
// })
353+
// .AddInMemoryStorage();
364354

365-
services.AddHealthChecksUI(setupSettings: setup =>
366-
{
367-
setup.AddHealthCheckEndpoint("Health Check", $"/healthz");
368-
})
369-
.AddInMemoryStorage();
355+
// return services;
356+
//}
370357

371-
return services;
372-
}
358+
//public static IServiceCollection AddHealthChecksMySQL<TDbContext>(this IServiceCollection services, string webAddressGroup, string webAddressTitle, string sqliteConnString) where TDbContext : DbContext
359+
//{
360+
// services.AddHealthChecks()
361+
// .AddDbContextCheck<TDbContext>(name: "Application DB Context", failureStatus: HealthStatus.Degraded)
362+
// .AddUrlGroup(new Uri(webAddressGroup), name: webAddressTitle, failureStatus: HealthStatus.Degraded)
363+
// .AddMySql(sqliteConnString);
373364

374-
public static IServiceCollection AddHealthChecksPostgreSQL<TDbContext>(this IServiceCollection services, string webAddressGroup, string webAddressTitle, string sqliteConnString) where TDbContext : DbContext
375-
{
376-
services.AddHealthChecks()
377-
.AddDbContextCheck<TDbContext>(name: "Application DB Context", failureStatus: HealthStatus.Degraded)
378-
.AddUrlGroup(new Uri(webAddressGroup), name: webAddressTitle, failureStatus: HealthStatus.Degraded)
379-
.AddNpgSql(sqliteConnString);
365+
// services.AddHealthChecksUI(setupSettings: setup =>
366+
// {
367+
// setup.AddHealthCheckEndpoint("Health Check", $"/healthz");
368+
// })
369+
// .AddInMemoryStorage();
380370

381-
services.AddHealthChecksUI(setupSettings: setup =>
382-
{
383-
setup.AddHealthCheckEndpoint("Health Check", $"/healthz");
384-
})
385-
.AddInMemoryStorage();
371+
// return services;
372+
//}
386373

387-
return services;
388-
}
374+
//public static IServiceCollection AddHealthChecksPostgreSQL<TDbContext>(this IServiceCollection services, string webAddressGroup, string webAddressTitle, string sqliteConnString) where TDbContext : DbContext
375+
//{
376+
// services.AddHealthChecks()
377+
// .AddDbContextCheck<TDbContext>(name: "Application DB Context", failureStatus: HealthStatus.Degraded)
378+
// .AddUrlGroup(new Uri(webAddressGroup), name: webAddressTitle, failureStatus: HealthStatus.Degraded)
379+
// .AddNpgSql(sqliteConnString);
389380

390-
public static WebApplication UseHealthChecksConfigure(this WebApplication app)
391-
{
392-
app.UseHealthChecks("/healthz", new HealthCheckOptions
393-
{
394-
Predicate = _ => true,
395-
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse,
396-
ResultStatusCodes =
397-
{
398-
[HealthStatus.Healthy] = StatusCodes.Status200OK,
399-
[HealthStatus.Degraded] = StatusCodes.Status500InternalServerError,
400-
[HealthStatus.Unhealthy] = StatusCodes.Status503ServiceUnavailable,
401-
},
402-
}).UseHealthChecksUI(setup =>
403-
{
404-
setup.ApiPath = "/healthcheck";
405-
setup.UIPath = "/healthcheck-ui";
381+
// services.AddHealthChecksUI(setupSettings: setup =>
382+
// {
383+
// setup.AddHealthCheckEndpoint("Health Check", $"/healthz");
384+
// })
385+
// .AddInMemoryStorage();
406386

407-
//https://github.com/Amitpnk/Onion-architecture-ASP.NET-Core/blob/develop/src/OA/Customization/custom.css
408-
//setup.AddCustomStylesheet("Customization/custom.css");
409-
});
387+
// return services;
388+
//}
410389

411-
return app;
412-
}
413-
#endregion
390+
//public static WebApplication UseHealthChecksConfigure(this WebApplication app)
391+
//{
392+
// app.UseHealthChecks("/healthz", new HealthCheckOptions
393+
// {
394+
// Predicate = _ => true,
395+
// ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse,
396+
// ResultStatusCodes =
397+
// {
398+
// [HealthStatus.Healthy] = StatusCodes.Status200OK,
399+
// [HealthStatus.Degraded] = StatusCodes.Status500InternalServerError,
400+
// [HealthStatus.Unhealthy] = StatusCodes.Status503ServiceUnavailable,
401+
// },
402+
// }).UseHealthChecksUI(setup =>
403+
// {
404+
// setup.ApiPath = "/healthcheck";
405+
// setup.UIPath = "/healthcheck-ui";
406+
407+
// //https://github.com/Amitpnk/Onion-architecture-ASP.NET-Core/blob/develop/src/OA/Customization/custom.css
408+
// //setup.AddCustomStylesheet("Customization/custom.css");
409+
// });
410+
411+
// return app;
412+
//}
413+
//#endregion
414414

415415
#region "SEND EMAIL"
416416
public static IServiceCollection AddMailKitEmailSenderService(this IServiceCollection services, IConfiguration configuration)

src/NET6CustomLibrary/GlobalUsings.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
global using System.Threading.Tasks;
1313
global using FluentValidation;
1414
global using FluentValidation.Results;
15-
global using HealthChecks.UI.Client;
1615
global using MailKit.Net.Smtp;
1716
global using MailKit.Security;
1817
global using MediatR;

src/NET6CustomLibrary/NET6CustomLibrary.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
</PropertyGroup>
1717

1818
<ItemGroup>
19-
<PackageReference Include="AspNetCore.HealthChecks.MySql" Version="6.0.2" />
19+
<!--<PackageReference Include="AspNetCore.HealthChecks.MySql" Version="6.0.2" />
2020
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="6.0.2" />
2121
<PackageReference Include="AspNetCore.HealthChecks.Sqlite" Version="6.0.2" />
2222
<PackageReference Include="AspNetCore.HealthChecks.SqlServer" Version="6.0.2" />
2323
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="6.0.5" />
2424
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="6.0.5" />
2525
<PackageReference Include="AspNetCore.HealthChecks.UI.InMemory.Storage" Version="6.0.5" />
26-
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="6.0.3" />
26+
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="6.0.3" />-->
2727
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
2828
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" />
2929
<PackageReference Include="MailKit" Version="4.0.0" />
@@ -39,8 +39,8 @@
3939
<PrivateAssets>all</PrivateAssets>
4040
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4141
</PackageReference>
42-
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="6.0.16" />
43-
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="6.0.16" />
42+
<!--<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="6.0.16" />
43+
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="6.0.16" />-->
4444
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
4545
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="6.0.0" />
4646
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
@@ -62,7 +62,7 @@
6262
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
6363
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
6464
<PackageReference Include="System.Text.Json" Version="6.0.7" />
65-
<PackageReference Include="SequentialGuid" Version="4.0.4" />
65+
<!--<PackageReference Include="SequentialGuid" Version="4.0.4" />-->
6666
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="6.0.16" />
6767
<PackageReference Include="MassTransit.AspNetCore" Version="7.3.1" />
6868
<PackageReference Include="MassTransit.RabbitMQ" Version="8.0.15" />

0 commit comments

Comments
 (0)