Some checks failed
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Failing after 9s
26 lines
797 B
C#
26 lines
797 B
C#
using PipeMethodCalls;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace HardwareMonitorStatusWindow.Service;
|
|
|
|
public class HardwarePipeSerializer : IPipeSerializer
|
|
{
|
|
private static readonly JsonSerializerOptions JsonSerializerOptions = new()
|
|
{
|
|
NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals
|
|
};
|
|
|
|
public object? Deserialize(byte[] data, Type type)
|
|
{
|
|
return JsonSerializer.Deserialize(data, type, JsonSerializerOptions);
|
|
}
|
|
|
|
public byte[] Serialize(object o)
|
|
{
|
|
using var memoryStream = new MemoryStream();
|
|
using var utf8JsonWriter = new Utf8JsonWriter(memoryStream);
|
|
JsonSerializer.Serialize(utf8JsonWriter, o, JsonSerializerOptions);
|
|
return memoryStream.ToArray();
|
|
}
|
|
} |