Repository URL to install this package:
Version:
1.3.1 ▾
|
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Fluctio.FluctioSim.EditorCore.Training.TensorboardApi
{
[JsonConverter(typeof(ScalarEventConverter))]
public record ScalarEvent(DateTime EventTime, int Step, float Value);
internal class ScalarEventConverter : JsonConverter<ScalarEvent>
{
public override ScalarEvent ReadJson(JsonReader reader, Type objectType, ScalarEvent existingValue, bool hasExistingValue, JsonSerializer serializer)
{
var array = serializer.Deserialize<List<JValue>>(reader);
return new ScalarEvent(
EventTime: DateTime.UnixEpoch.AddSeconds((double)array[0]),
Step: (int)array[1],
Value: (float)array[2]
);
}
public override void WriteJson(JsonWriter writer, ScalarEvent value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
}
}