1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Nodes - Serialize node storage ourselves to ignore exceptions

This commit is contained in:
Robert 2021-08-21 15:33:55 +02:00
parent a4667fdc03
commit 405d5b756c
5 changed files with 16 additions and 5 deletions

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Reflection;
using Artemis.Storage.Entities.Profile.Nodes;
using Newtonsoft.Json;
using Ninject;
using Ninject.Parameters;
using SkiaSharp;
@ -73,7 +74,14 @@ namespace Artemis.Core.Services
{
node.X = entity.X;
node.Y = entity.Y;
node.Storage = entity.Storage;
try
{
node.Storage = CoreJson.DeserializeObject(entity.Storage, true);
}
catch
{
// ignored
}
}
if (node is CustomViewModelNode customViewModelNode)

View File

@ -12,7 +12,7 @@ namespace Artemis.Core
public double X { get; set; }
public double Y { get; set; }
public object Storage { get; set; }
public object? Storage { get; set; }
public IReadOnlyCollection<IPin> Pins { get; }
public IReadOnlyCollection<IPinCollection> PinCollections { get; }

View File

@ -96,7 +96,7 @@ namespace Artemis.Core
continue;
nodes.Add(entityNode.Id, node);
}
LoadConnections(nodes);
_nodes.Clear();
@ -179,7 +179,7 @@ namespace Artemis.Core
Type = node.GetType().Name,
X = node.X,
Y = node.Y,
Storage = node.Storage,
Storage = CoreJson.SerializeObject(node.Storage, true),
Name = node.Name,
Description = node.Description,
IsExitNode = node.IsExitNode

View File

@ -19,7 +19,7 @@ namespace Artemis.Storage.Entities.Profile.Nodes
public bool IsExitNode { get; set; }
public double X { get; set; }
public double Y { get; set; }
public object Storage { get; set; }
public string Storage { get; set; }
public List<NodePinCollectionEntity> PinCollections { get; set; }
}

View File

@ -88,6 +88,9 @@ namespace Artemis.VisualScripting.Nodes
public override void Evaluate()
{
if (Storage is double doubleValue)
Storage = (float) doubleValue;
Output.Value = Storage as float? ?? 0.0f;
}