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

Commit abf6790

Browse files
committed
Deprecato metodo AddDateTimeOnlyAttributes
1 parent 6f50f0f commit abf6790

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/NET6CustomLibrary/Extensions/DependencyInjection.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public static IMvcBuilder AddDateTimeJsonOptions(this IMvcBuilder builder)
7272
return builder;
7373
}
7474

75+
[Obsolete("This method is deprecated. Please indicate the TypeDescriptors as indicated in the README", true)]
7576
public static IServiceCollection AddDateTimeOnlyAttributes(this IServiceCollection services)
7677
{
7778
TypeDescriptor.AddAttributes(typeof(DateOnly), new TypeConverterAttribute(typeof(DateOnlyTypeConverter)));
@@ -167,6 +168,27 @@ public static IServiceCollection AddMySqlHealthChecks(this IServiceCollection se
167168
return services;
168169
}
169170

171+
public static IServiceCollection AddPostgresHealthChecks(this IServiceCollection services, string connectionString, string nameAsyncCheck)
172+
{
173+
services.AddHealthChecks()
174+
.AddAsyncCheck(nameAsyncCheck, async () =>
175+
{
176+
try
177+
{
178+
using var connection = new NpgsqlConnection(connectionString);
179+
await connection.OpenAsync();
180+
}
181+
catch (Exception ex)
182+
{
183+
return HealthCheckResult.Unhealthy(ex.Message, ex);
184+
}
185+
186+
return HealthCheckResult.Healthy();
187+
});
188+
189+
return services;
190+
}
191+
170192
public static IEndpointRouteBuilder AddDatabaseHealthChecks(this IEndpointRouteBuilder builder, string pattern)
171193
{
172194
builder.MapHealthChecks(pattern, new HealthCheckOptions

0 commit comments

Comments
 (0)