mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 09:48:26 -04:00
Global usings and file scoped namespaces
This commit is contained in:
@@ -1,28 +1,27 @@
|
||||
using System.Text.Json;
|
||||
using NadekoBot.Common.JsonConverters;
|
||||
|
||||
namespace NadekoBot.Common
|
||||
{
|
||||
public class JsonSeria : ISeria
|
||||
{
|
||||
private JsonSerializerOptions serializerOptions = new JsonSerializerOptions()
|
||||
{
|
||||
Converters =
|
||||
{
|
||||
new Rgba32Converter(),
|
||||
new CultureInfoConverter(),
|
||||
}
|
||||
};
|
||||
public byte[] Serialize<T>(T data)
|
||||
=> JsonSerializer.SerializeToUtf8Bytes(data, serializerOptions);
|
||||
namespace NadekoBot.Common;
|
||||
|
||||
public T Deserialize<T>(byte[] data)
|
||||
public class JsonSeria : ISeria
|
||||
{
|
||||
private JsonSerializerOptions serializerOptions = new JsonSerializerOptions()
|
||||
{
|
||||
Converters =
|
||||
{
|
||||
if (data is null)
|
||||
return default;
|
||||
new Rgba32Converter(),
|
||||
new CultureInfoConverter(),
|
||||
}
|
||||
};
|
||||
public byte[] Serialize<T>(T data)
|
||||
=> JsonSerializer.SerializeToUtf8Bytes(data, serializerOptions);
|
||||
|
||||
public T Deserialize<T>(byte[] data)
|
||||
{
|
||||
if (data is null)
|
||||
return default;
|
||||
|
||||
|
||||
return JsonSerializer.Deserialize<T>(data, serializerOptions);
|
||||
}
|
||||
return JsonSerializer.Deserialize<T>(data, serializerOptions);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user