NrxDebugVisualizer shows objects.
TODO: Update SceneTreeView after adding new objects
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
namespace NamedPipes;
|
||||
|
||||
public interface IDebugVisualizer
|
||||
|
||||
@@ -10,18 +10,25 @@ namespace NamedPipes;
|
||||
/// </summary>
|
||||
public class PipeSerializer : IPipeSerializer
|
||||
{
|
||||
private JsonSerializerOptions options = new()
|
||||
{
|
||||
IncludeFields = true
|
||||
};
|
||||
|
||||
public object Deserialize(byte[] data, Type type)
|
||||
{
|
||||
return JsonSerializer.Deserialize(data, type) ?? throw new InvalidDataException($"Can not deserialize to type: {type} ");
|
||||
|
||||
var obj = JsonSerializer.Deserialize(data, type, options) ?? throw new InvalidDataException($"Can not deserialize to type: {type} ");
|
||||
return obj;
|
||||
}
|
||||
|
||||
public byte[] Serialize(object o)
|
||||
{
|
||||
using (var memoryStream = new MemoryStream())
|
||||
using (var utf8JsonWriter = new Utf8JsonWriter(memoryStream))
|
||||
{
|
||||
JsonSerializer.Serialize(utf8JsonWriter, o);
|
||||
return memoryStream.ToArray();
|
||||
}
|
||||
|
||||
using var memoryStream = new MemoryStream();
|
||||
using var utf8JsonWriter = new Utf8JsonWriter(memoryStream);
|
||||
JsonSerializer.Serialize(utf8JsonWriter, o, options);
|
||||
var data = memoryStream.ToArray();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user