refactor: refinamentos
This commit is contained in:
@@ -183,6 +183,8 @@ visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public
|
||||
# .NET Diagnostic #
|
||||
###############################
|
||||
|
||||
[*.{cs,vb}]
|
||||
|
||||
# Simplify name
|
||||
dotnet_diagnostic.IDE0001.severity = warning
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace Shop.Core.Extensions;
|
||||
|
||||
public static class JsonExtensions
|
||||
{
|
||||
private static readonly JsonSerializerOptions JsonOptions = new JsonSerializerOptions().Configure();
|
||||
private static readonly Lazy<JsonSerializerOptions> LazyOptions =
|
||||
new(() => new JsonSerializerOptions().Configure(), isThreadSafe: true);
|
||||
|
||||
/// <summary>
|
||||
/// Converts a JSON string to an object of type T.
|
||||
@@ -17,7 +18,7 @@ public static class JsonExtensions
|
||||
/// <param name="value">The JSON string to deserialize.</param>
|
||||
/// <returns>The deserialized object of type T.</returns>
|
||||
public static T FromJson<T>(this string value) =>
|
||||
value != null ? JsonSerializer.Deserialize<T>(value, JsonOptions) : default;
|
||||
value != null ? JsonSerializer.Deserialize<T>(value, LazyOptions.Value) : default;
|
||||
|
||||
/// <summary>
|
||||
/// Converts an object to JSON string.
|
||||
@@ -26,7 +27,7 @@ public static class JsonExtensions
|
||||
/// <param name="value">The object to convert.</param>
|
||||
/// <returns>The JSON string representation of the object.</returns>
|
||||
public static string ToJson<T>(this T value) =>
|
||||
value != null ? JsonSerializer.Serialize(value, JsonOptions) : default;
|
||||
value != null ? JsonSerializer.Serialize(value, LazyOptions.Value) : default;
|
||||
|
||||
/// <summary>
|
||||
/// Configures the JsonSerializerOptions instance.
|
||||
|
||||
@@ -35,7 +35,16 @@ internal static class ServicesCollectionExtensions
|
||||
{
|
||||
Version = "v1",
|
||||
Title = "Shop (e-commerce)",
|
||||
Description = "ASP.NET Core C# CQRS Event Sourcing, REST API, DDD, SOLID Principles and Clean Architecture"
|
||||
Description = "ASP.NET Core C# CQRS Event Sourcing, REST API, DDD, SOLID Principles and Clean Architecture",
|
||||
Contact = new OpenApiContact
|
||||
{
|
||||
Name = "Jean Gatto",
|
||||
Email = "jean_gatto@hotmail.com"
|
||||
},
|
||||
License = new OpenApiLicense
|
||||
{
|
||||
Name = "MIT License"
|
||||
}
|
||||
});
|
||||
|
||||
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
|
||||
|
||||
Reference in New Issue
Block a user