-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNodeDebug.cs
More file actions
82 lines (69 loc) · 2.18 KB
/
NodeDebug.cs
File metadata and controls
82 lines (69 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using NodeSharp.Nodes.Common;
using NodeSharp.Nodes.Common.Model;
namespace NodeSharp.Nodes.Debug;
public class NodeDebug : BaseNode
{
public NodeDebug(
BaseNodeList nodes,
string id,
string typeId,
string name,
bool isEnabled,
bool activateOnStart,
int xPosition,
int yPosition,
Storage storage,
Color backgroundColor)
: base(nodes, id, typeId, name, isEnabled, activateOnStart, xPosition, yPosition, storage, backgroundColor)
{
const double height = 70;
const double width = 220;
const double bodyHeight = 12;
BoxDimension = new Rect(0, 0, width, height);
Inputs.Clear();
Outputs.Clear();
Inputs.Add(new Input(Guid.CreateVersion7(), "Input", [], new Point(0, (height - bodyHeight) / 2)));
}
public NodeDebug(
BaseNodeList nodes,
string id,
string typeId,
string name,
bool isEnabled,
bool activateOnStart,
int xPosition,
int yPosition,
List<Output> outputs,
List<Input> inputs,
JsonElement nodeElement)
: base(nodes, id, typeId, name, isEnabled, activateOnStart, xPosition, yPosition, outputs, inputs)
{
}
protected override async Task<JsonNode?> RunFromInput(BaseNode parentNode, string inputJsonString)
{
var stopwatch = EnterNode(this);
try
{
var fromInput = await base.RunFromInput(parentNode, inputJsonString);
if (fromInput is null)
{
throw new InvalidOperationException($"NodeDebug '{Name}' has no input data.");
}
OutputMessage = inputJsonString;
System.Diagnostics.Debug.WriteLine($"{Name}: {inputJsonString}");
ExitNodeMessage(
this,
"Output",
fromInput.ToJsonString(new JsonSerializerOptions { WriteIndented = true }),
Name);
return fromInput;
}
finally
{
LeaveNode(this, stopwatch);
}
}
}