mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 09:43:46 +00:00
Nodes - Serialize node storage ourselves to ignore exceptions
This commit is contained in:
parent
a4667fdc03
commit
405d5b756c
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Artemis.Storage.Entities.Profile.Nodes;
|
using Artemis.Storage.Entities.Profile.Nodes;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using Ninject.Parameters;
|
using Ninject.Parameters;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
@ -73,7 +74,14 @@ namespace Artemis.Core.Services
|
|||||||
{
|
{
|
||||||
node.X = entity.X;
|
node.X = entity.X;
|
||||||
node.Y = entity.Y;
|
node.Y = entity.Y;
|
||||||
node.Storage = entity.Storage;
|
try
|
||||||
|
{
|
||||||
|
node.Storage = CoreJson.DeserializeObject(entity.Storage, true);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node is CustomViewModelNode customViewModelNode)
|
if (node is CustomViewModelNode customViewModelNode)
|
||||||
|
|||||||
@ -12,7 +12,7 @@ namespace Artemis.Core
|
|||||||
|
|
||||||
public double X { get; set; }
|
public double X { get; set; }
|
||||||
public double Y { get; set; }
|
public double Y { get; set; }
|
||||||
public object Storage { get; set; }
|
public object? Storage { get; set; }
|
||||||
|
|
||||||
public IReadOnlyCollection<IPin> Pins { get; }
|
public IReadOnlyCollection<IPin> Pins { get; }
|
||||||
public IReadOnlyCollection<IPinCollection> PinCollections { get; }
|
public IReadOnlyCollection<IPinCollection> PinCollections { get; }
|
||||||
|
|||||||
@ -179,7 +179,7 @@ namespace Artemis.Core
|
|||||||
Type = node.GetType().Name,
|
Type = node.GetType().Name,
|
||||||
X = node.X,
|
X = node.X,
|
||||||
Y = node.Y,
|
Y = node.Y,
|
||||||
Storage = node.Storage,
|
Storage = CoreJson.SerializeObject(node.Storage, true),
|
||||||
Name = node.Name,
|
Name = node.Name,
|
||||||
Description = node.Description,
|
Description = node.Description,
|
||||||
IsExitNode = node.IsExitNode
|
IsExitNode = node.IsExitNode
|
||||||
|
|||||||
@ -19,7 +19,7 @@ namespace Artemis.Storage.Entities.Profile.Nodes
|
|||||||
public bool IsExitNode { get; set; }
|
public bool IsExitNode { get; set; }
|
||||||
public double X { get; set; }
|
public double X { get; set; }
|
||||||
public double Y { get; set; }
|
public double Y { get; set; }
|
||||||
public object Storage { get; set; }
|
public string Storage { get; set; }
|
||||||
|
|
||||||
public List<NodePinCollectionEntity> PinCollections { get; set; }
|
public List<NodePinCollectionEntity> PinCollections { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -88,6 +88,9 @@ namespace Artemis.VisualScripting.Nodes
|
|||||||
|
|
||||||
public override void Evaluate()
|
public override void Evaluate()
|
||||||
{
|
{
|
||||||
|
if (Storage is double doubleValue)
|
||||||
|
Storage = (float) doubleValue;
|
||||||
|
|
||||||
Output.Value = Storage as float? ?? 0.0f;
|
Output.Value = Storage as float? ?? 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user