-
Notifications
You must be signed in to change notification settings - Fork 151
/
Copy pathPrintNode.cs
53 lines (47 loc) · 1.53 KB
/
PrintNode.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using System.Text;
using System.Threading.Tasks;
using DynamicData;
using ExampleCodeGenApp.Model;
using ExampleCodeGenApp.Model.Compiler;
using ExampleCodeGenApp.Views;
using NodeNetwork.Toolkit.ValueNode;
using NodeNetwork.ViewModels;
using ReactiveUI;
namespace ExampleCodeGenApp.ViewModels.Nodes
{
public class PrintNode : CodeGenNodeViewModel
{
static PrintNode()
{
Splat.Locator.CurrentMutable.Register(() => new CodeGenNodeView(), typeof(IViewFor<PrintNode>));
}
public ValueNodeInputViewModel<ITypedExpression<string>> Text { get; }
public ValueNodeOutputViewModel<IStatement> Flow { get; }
public PrintNode() : base(NodeType.Function)
{
this.Name = "Print";
Text = new CodeGenInputViewModel<ITypedExpression<string>>(PortType.String)
{
Name = "Text"
};
this.EditableInputs().Add(Text);
Flow = new CodeGenOutputViewModel<IStatement>(PortType.Execution)
{
Name = "",
Value = this.Text.ValueChanged.Select(stringExpr => new FunctionCall
{
FunctionName = "print",
Parameters =
{
stringExpr ?? new StringLiteral{Value = ""}
}
})
};
this.EditableOutputs().Add(Flow);
}
}
}