diff --git a/Bindings/JSON/JsonAddToObject.cs b/Bindings/JSON/JsonAddToObject.cs new file mode 100644 index 0000000..ebb2a6f --- /dev/null +++ b/Bindings/JSON/JsonAddToObject.cs @@ -0,0 +1,71 @@ +using System; +using Elements.Core; +using FrooxEngine; +using FrooxEngine.ProtoFlux; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; +using Newtonsoft.Json.Linq; + + + [Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] + public class JsonAddToObjectBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode + { + public readonly SyncRef> Input; + public readonly SyncRef> Tag; + public readonly SyncRef> Object; + + public override Type NodeType => typeof(JsonAddToObject); + + public JsonAddToObject TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => base.NodeInputCount + 3; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + JsonAddToObject jsonAddToObjectInstance = (TypedNodeInstance = new JsonAddToObject()); + return jsonAddToObjectInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonAddToObject typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(JsonAddToObject)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + + protected override ISyncRef GetInputInternal(ref int index) + { + ISyncRef inputInternal = base.GetInputInternal(ref index); + if (inputInternal != null) + { + return inputInternal; + } + switch (index) + { + case 0: + return Input; + case 1: + return Tag; + case 2: + return Object; + default: + index -= 3; + return null; + } + } + } diff --git a/Bindings/JSON/JsonAppendToArrayBinding.cs b/Bindings/JSON/JsonAppendToArrayBinding.cs new file mode 100644 index 0000000..e025a99 --- /dev/null +++ b/Bindings/JSON/JsonAppendToArrayBinding.cs @@ -0,0 +1,68 @@ +using System; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; +using Newtonsoft.Json.Linq; +using FrooxEngine.ProtoFlux; + + [Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] + public class JsonAppendToArrayBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode + { + public readonly SyncRef> Array; + public readonly SyncRef> Object; + + public override Type NodeType => typeof(JsonAppendToArray); + + public JsonAppendToArray TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => base.NodeInputCount + 2; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + JsonAppendToArray jsonAppendToArrayInstance = (TypedNodeInstance = new JsonAppendToArray()); + return jsonAppendToArrayInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonAppendToArray typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(JsonAppendToArray)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + + protected override ISyncRef GetInputInternal(ref int index) + { + ISyncRef inputInternal = base.GetInputInternal(ref index); + if (inputInternal != null) + { + return inputInternal; + } + switch (index) + { + case 0: + return Array; + case 1: + return Object; + default: + index -= 2; + return null; + } + } + } + diff --git a/Bindings/JSON/JsonCountArrayChildrenBinding.cs b/Bindings/JSON/JsonCountArrayChildrenBinding.cs new file mode 100644 index 0000000..06bec6b --- /dev/null +++ b/Bindings/JSON/JsonCountArrayChildrenBinding.cs @@ -0,0 +1,62 @@ +using System; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; +using Newtonsoft.Json.Linq; +using FrooxEngine.ProtoFlux; + + [Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] + public class JsonCountArrayChildrenBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ValueFunctionNode + { + public readonly SyncRef> Input; + + public override Type NodeType => typeof(JsonCountArrayChildrenNode); + + public JsonCountArrayChildrenNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => base.NodeInputCount + 1; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + JsonCountArrayChildrenNode jsonCountArrayChildrenInstance = (TypedNodeInstance = new JsonCountArrayChildrenNode()); + return jsonCountArrayChildrenInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonCountArrayChildrenNode typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(JsonCountArrayChildrenNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + + protected override ISyncRef GetInputInternal(ref int index) + { + ISyncRef inputInternal = base.GetInputInternal(ref index); + if (inputInternal != null) + { + return inputInternal; + } + if (index == 0) + { + return Input; + } + index -= 1; + return null; + } + } diff --git a/Bindings/JSON/JsonCountObjectChildrenBinding.cs b/Bindings/JSON/JsonCountObjectChildrenBinding.cs new file mode 100644 index 0000000..6a9a4bb --- /dev/null +++ b/Bindings/JSON/JsonCountObjectChildrenBinding.cs @@ -0,0 +1,63 @@ +using System; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; +using Newtonsoft.Json.Linq; +using FrooxEngine.ProtoFlux; + + + [Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] + public class JsonCountObjectChildrenBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ValueFunctionNode + { + public readonly SyncRef> Input; + + public override Type NodeType => typeof(JsonCountObjectChildrenNode); + + public JsonCountObjectChildrenNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => base.NodeInputCount + 1; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + JsonCountObjectChildrenNode jsonCountObjectChildrenInstance = (TypedNodeInstance = new JsonCountObjectChildrenNode()); + return jsonCountObjectChildrenInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonCountObjectChildrenNode typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(JsonCountObjectChildrenNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + + protected override ISyncRef GetInputInternal(ref int index) + { + ISyncRef inputInternal = base.GetInputInternal(ref index); + if (inputInternal != null) + { + return inputInternal; + } + if (index == 0) + { + return Input; + } + index -= 1; + return null; + } + } diff --git a/Bindings/JSON/JsonEmptyArrayBinding.cs b/Bindings/JSON/JsonEmptyArrayBinding.cs new file mode 100644 index 0000000..c454615 --- /dev/null +++ b/Bindings/JSON/JsonEmptyArrayBinding.cs @@ -0,0 +1,42 @@ +using System; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using Newtonsoft.Json.Linq; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; + +[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] + public class JsonEmptyArrayBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode + { + public override Type NodeType => typeof(JsonEmptyArrayNode); + + public JsonEmptyArrayNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => 0; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + throw new InvalidOperationException("Node has already been instantiated"); + + TypedNodeInstance = new JsonEmptyArrayNode(); + return TypedNodeInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonEmptyArrayNode typedNodeInstance) + TypedNodeInstance = typedNodeInstance; + else + throw new ArgumentException("Node instance is not of type " + typeof(JsonEmptyArrayNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + } + diff --git a/Bindings/JSON/JsonEmptyObjectBinding.cs b/Bindings/JSON/JsonEmptyObjectBinding.cs new file mode 100644 index 0000000..ca4997c --- /dev/null +++ b/Bindings/JSON/JsonEmptyObjectBinding.cs @@ -0,0 +1,42 @@ +using System; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using Newtonsoft.Json.Linq; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; + +[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] + public class JsonEmptyObjectBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode + { + public override Type NodeType => typeof(JsonEmptyObjectNode); + + public JsonEmptyObjectNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => 0; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + throw new InvalidOperationException("Node has already been instantiated"); + + TypedNodeInstance = new JsonEmptyObjectNode(); + return TypedNodeInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonEmptyObjectNode typedNodeInstance) + TypedNodeInstance = typedNodeInstance; + else + throw new ArgumentException("Node instance is not of type " + typeof(JsonEmptyObjectNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + } + diff --git a/Bindings/JSON/JsonGetFromArrayBinding.cs b/Bindings/JSON/JsonGetFromArrayBinding.cs new file mode 100644 index 0000000..d4835ae --- /dev/null +++ b/Bindings/JSON/JsonGetFromArrayBinding.cs @@ -0,0 +1,69 @@ +using System; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; +using Newtonsoft.Json.Linq; +using FrooxEngine.ProtoFlux; + + + [Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] + public class JsonGetFromArrayBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode + { + public readonly SyncRef> Input; + public readonly SyncRef> Index; + + public override Type NodeType => typeof(JsonGetFromArrayNode); + + public JsonGetFromArrayNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => base.NodeInputCount + 2; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + JsonGetFromArrayNode jsonGetFromArrayInstance = (TypedNodeInstance = new JsonGetFromArrayNode()); + return jsonGetFromArrayInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonGetFromArrayNode typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(JsonGetFromArrayNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + + protected override ISyncRef GetInputInternal(ref int index) + { + ISyncRef inputInternal = base.GetInputInternal(ref index); + if (inputInternal != null) + { + return inputInternal; + } + switch (index) + { + case 0: + return Input; + case 1: + return Index; + default: + index -= 2; + return null; + } + } + } + diff --git a/Bindings/JSON/JsonGetFromObjectBinding.cs b/Bindings/JSON/JsonGetFromObjectBinding.cs new file mode 100644 index 0000000..91fec2a --- /dev/null +++ b/Bindings/JSON/JsonGetFromObjectBinding.cs @@ -0,0 +1,68 @@ +using System; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; +using Newtonsoft.Json.Linq; +using FrooxEngine.ProtoFlux; + + + [Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] + public class JsonGetFromObjectBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode + { + public readonly SyncRef> Input; + public readonly SyncRef> Tag; + + public override Type NodeType => typeof(JsonGetFromObjectNode); + + public JsonGetFromObjectNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => base.NodeInputCount + 2; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + JsonGetFromObjectNode jsonGetFromObjectInstance = (TypedNodeInstance = new JsonGetFromObjectNode()); + return jsonGetFromObjectInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonGetFromObjectNode typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(JsonGetFromObjectNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + + protected override ISyncRef GetInputInternal(ref int index) + { + ISyncRef inputInternal = base.GetInputInternal(ref index); + if (inputInternal != null) + { + return inputInternal; + } + switch (index) + { + case 0: + return Input; + case 1: + return Tag; + default: + index -= 2; + return null; + } + } + } diff --git a/Bindings/JSON/JsonInsertToArrayBinding.cs b/Bindings/JSON/JsonInsertToArrayBinding.cs new file mode 100644 index 0000000..e63a605 --- /dev/null +++ b/Bindings/JSON/JsonInsertToArrayBinding.cs @@ -0,0 +1,71 @@ +using System; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; +using Newtonsoft.Json.Linq; +using FrooxEngine.ProtoFlux; + + + [Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] + public class JsonInsertToArrayBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode + { + public readonly SyncRef> Array; + public readonly SyncRef> Object; + public readonly SyncRef> Index; + + public override Type NodeType => typeof(JsonInsertToArrayNode); + + public JsonInsertToArrayNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => base.NodeInputCount + 3; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + JsonInsertToArrayNode jsonInsertToArrayInstance = (TypedNodeInstance = new JsonInsertToArrayNode()); + return jsonInsertToArrayInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonInsertToArrayNode typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(JsonInsertToArrayNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + + protected override ISyncRef GetInputInternal(ref int index) + { + ISyncRef inputInternal = base.GetInputInternal(ref index); + if (inputInternal != null) + { + return inputInternal; + } + switch (index) + { + case 0: + return Array; + case 1: + return Object; + case 2: + return Index; + default: + index -= 3; + return null; + } + } + } diff --git a/Bindings/JSON/JsonNullValueBinding.cs b/Bindings/JSON/JsonNullValueBinding.cs new file mode 100644 index 0000000..a716b5d --- /dev/null +++ b/Bindings/JSON/JsonNullValueBinding.cs @@ -0,0 +1,42 @@ +using System; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using Newtonsoft.Json.Linq; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; + +[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] + public class JsonNullValueBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode + { + public override Type NodeType => typeof(JsonNullValueNode); + + public JsonNullValueNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => 0; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + throw new InvalidOperationException("Node has already been instantiated"); + + TypedNodeInstance = new JsonNullValueNode(); + return TypedNodeInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonNullValueNode typedNodeInstance) + TypedNodeInstance = typedNodeInstance; + else + throw new ArgumentException("Node instance is not of type " + typeof(JsonNullValueNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + } + diff --git a/Bindings/JSON/JsonParseStringArrayBinding.cs b/Bindings/JSON/JsonParseStringArrayBinding.cs new file mode 100644 index 0000000..c706250 --- /dev/null +++ b/Bindings/JSON/JsonParseStringArrayBinding.cs @@ -0,0 +1,63 @@ +using System; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; +using Newtonsoft.Json.Linq; +using FrooxEngine.ProtoFlux; + + + [Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] + public class JsonParseStringArrayBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode + { + public readonly SyncRef> Input; + + public override Type NodeType => typeof(JsonParseStringArrayNode); + + public JsonParseStringArrayNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => base.NodeInputCount + 1; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + JsonParseStringArrayNode jsonParseStringArrayInstance = (TypedNodeInstance = new JsonParseStringArrayNode()); + return jsonParseStringArrayInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonParseStringArrayNode typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(JsonParseStringArrayNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + + protected override ISyncRef GetInputInternal(ref int index) + { + ISyncRef inputInternal = base.GetInputInternal(ref index); + if (inputInternal != null) + { + return inputInternal; + } + if (index == 0) + { + return Input; + } + index -= 1; + return null; + } + } diff --git a/Bindings/JSON/JsonParseStringBinding.cs b/Bindings/JSON/JsonParseStringBinding.cs new file mode 100644 index 0000000..5079e2a --- /dev/null +++ b/Bindings/JSON/JsonParseStringBinding.cs @@ -0,0 +1,63 @@ +using System; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; +using Newtonsoft.Json.Linq; +using FrooxEngine.ProtoFlux; + + +[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] +public class JsonParseStringBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode +{ + public readonly SyncRef> Input; + + public override Type NodeType => typeof(JsonParseStringNode); + + public JsonParseStringNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => base.NodeInputCount + 1; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + JsonParseStringNode jsonParseStringArrayInstance = (TypedNodeInstance = new JsonParseStringNode()); + return jsonParseStringArrayInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonParseStringNode typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(JsonParseStringNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + + protected override ISyncRef GetInputInternal(ref int index) + { + ISyncRef inputInternal = base.GetInputInternal(ref index); + if (inputInternal != null) + { + return inputInternal; + } + if (index == 0) + { + return Input; + } + index -= 1; + return null; + } +} diff --git a/Bindings/JSON/JsonQuickGetFromObjectBinding.cs b/Bindings/JSON/JsonQuickGetFromObjectBinding.cs new file mode 100644 index 0000000..0c0e2ce --- /dev/null +++ b/Bindings/JSON/JsonQuickGetFromObjectBinding.cs @@ -0,0 +1,68 @@ +using System; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; +using Newtonsoft.Json.Linq; +using FrooxEngine.ProtoFlux; + + + [Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] + public class JsonQuickGetFromObjectBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode + { + public readonly SyncRef> Input; + public readonly SyncRef> Tag; + + public override Type NodeType => typeof(JsonQuickGetFromObjectNode); + + public JsonQuickGetFromObjectNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => base.NodeInputCount + 2; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + JsonQuickGetFromObjectNode jsonQuickGetFromObjectInstance = (TypedNodeInstance = new JsonQuickGetFromObjectNode()); + return jsonQuickGetFromObjectInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonQuickGetFromObjectNode typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(JsonQuickGetFromObjectNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + + protected override ISyncRef GetInputInternal(ref int index) + { + ISyncRef inputInternal = base.GetInputInternal(ref index); + if (inputInternal != null) + { + return inputInternal; + } + switch (index) + { + case 0: + return Input; + case 1: + return Tag; + default: + index -= 2; + return null; + } + } + } diff --git a/Bindings/JSON/JsonRemoveFromArrayBinding.cs b/Bindings/JSON/JsonRemoveFromArrayBinding.cs new file mode 100644 index 0000000..c02665c --- /dev/null +++ b/Bindings/JSON/JsonRemoveFromArrayBinding.cs @@ -0,0 +1,68 @@ +using System; +using Elements.Core; +using FrooxEngine; +using FrooxEngine.ProtoFlux; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; +using Newtonsoft.Json.Linq; + + +[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] +public class JsonRemoveFromArrayBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode +{ + public readonly SyncRef> Array; + public readonly SyncRef> Index; + + public override Type NodeType => typeof(JsonRemoveFromArrayNode); + + public JsonRemoveFromArrayNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => base.NodeInputCount + 2; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + JsonRemoveFromArrayNode jsonAddToObjectInstance = (TypedNodeInstance = new JsonRemoveFromArrayNode()); + return jsonAddToObjectInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonRemoveFromArrayNode typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(JsonRemoveFromArrayNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + + protected override ISyncRef GetInputInternal(ref int index) + { + ISyncRef inputInternal = base.GetInputInternal(ref index); + if (inputInternal != null) + { + return inputInternal; + } + switch (index) + { + case 0: + return Array; + case 1: + return Index; + default: + index -= 2; + return null; + } + } +} diff --git a/Bindings/JSON/JsonRemoveFromObjectBinding.cs b/Bindings/JSON/JsonRemoveFromObjectBinding.cs new file mode 100644 index 0000000..66ddfa8 --- /dev/null +++ b/Bindings/JSON/JsonRemoveFromObjectBinding.cs @@ -0,0 +1,68 @@ +using System; +using Elements.Core; +using FrooxEngine; +using FrooxEngine.ProtoFlux; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; +using Newtonsoft.Json.Linq; + + +[Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] +public class JsonRemoveFromObjectBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode +{ + public readonly SyncRef> Input; + public readonly SyncRef> Tag; + + public override Type NodeType => typeof(JsonRemoveFromObjectNode); + + public JsonRemoveFromObjectNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => base.NodeInputCount + 2; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + JsonRemoveFromObjectNode jsonAddToObjectInstance = (TypedNodeInstance = new JsonRemoveFromObjectNode()); + return jsonAddToObjectInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonRemoveFromObjectNode typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(JsonRemoveFromObjectNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + + protected override ISyncRef GetInputInternal(ref int index) + { + ISyncRef inputInternal = base.GetInputInternal(ref index); + if (inputInternal != null) + { + return inputInternal; + } + switch (index) + { + case 0: + return Input; + case 1: + return Tag; + default: + index -= 2; + return null; + } + } +} diff --git a/Bindings/JSON/JsonToStringBinding.cs b/Bindings/JSON/JsonToStringBinding.cs new file mode 100644 index 0000000..56783d3 --- /dev/null +++ b/Bindings/JSON/JsonToStringBinding.cs @@ -0,0 +1,63 @@ +using System; +using Elements.Core; +using FrooxEngine; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; +using Newtonsoft.Json.Linq; +using FrooxEngine.ProtoFlux; + + + [Category(new string[] { "ProtoFlux/Runtimes/Execution/Nodes/Obsidian/Json" })] + public class JsonToStringBinding : FrooxEngine.ProtoFlux.Runtimes.Execution.ObjectFunctionNode where T : JToken + { + public readonly SyncRef> Input; + + public override Type NodeType => typeof(JsonToStringNode); + + public JsonToStringNode TypedNodeInstance { get; private set; } + + public override INode NodeInstance => TypedNodeInstance; + + public override int NodeInputCount => base.NodeInputCount + 1; + + public override N Instantiate() + { + if (TypedNodeInstance != null) + { + throw new InvalidOperationException("Node has already been instantiated"); + } + JsonToStringNode jsonToStringInstance = (TypedNodeInstance = new JsonToStringNode()); + return jsonToStringInstance as N; + } + + protected override void AssociateInstanceInternal(INode node) + { + if (node is JsonToStringNode typedNodeInstance) + { + TypedNodeInstance = typedNodeInstance; + return; + } + throw new ArgumentException("Node instance is not of type " + typeof(JsonToStringNode)); + } + + public override void ClearInstance() + { + TypedNodeInstance = null; + } + + protected override ISyncRef GetInputInternal(ref int index) + { + ISyncRef inputInternal = base.GetInputInternal(ref index); + if (inputInternal != null) + { + return inputInternal; + } + if (index == 0) + { + return Input; + } + index -= 1; + return null; + } + } diff --git a/ProjectObsidian.csproj b/ProjectObsidian.csproj index 646ffcc..0f55af4 100644 --- a/ProjectObsidian.csproj +++ b/ProjectObsidian.csproj @@ -25,6 +25,9 @@ $(ResonitePath)Resonite_Data/Managed/FrooxEngine.dll + + ..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Resonite\Resonite_Data\Managed\Newtonsoft.Json.dll + $(ResonitePath)Resonite_Data/Managed/ProtoFlux.Core.dll diff --git a/ProtoFlux/JSON/JsonAddToObject.cs b/ProtoFlux/JSON/JsonAddToObject.cs new file mode 100644 index 0000000..2751ef2 --- /dev/null +++ b/ProtoFlux/JSON/JsonAddToObject.cs @@ -0,0 +1,42 @@ +using System; +using Newtonsoft.Json.Linq; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using Elements.Core; +using FrooxEngine; +using FrooxEngine.ProtoFlux; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + [NodeName("Add To Object")] + [Category("Protoflux/Obsidian/Json")] + [GenericTypes(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), + typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(string), typeof(Uri), + typeof(JToken), typeof(JObject), typeof(JArray))] + public class JsonAddToObject : ObjectFunctionNode + { + public readonly ObjectInput Input; + public readonly ObjectInput Tag; + public readonly ObjectInput Object; + + protected override JObject Compute(FrooxEngineContext context) + { + var input = Input.Evaluate(context); + if (input == null) return null; + + var tag = Tag.Evaluate(context); + var obj = Object.Evaluate(context); + if (string.IsNullOrEmpty(tag) || obj == null) return input; + + var in2 = (JObject)input.DeepClone(); + in2[tag] = obj switch + { + JArray jArray => jArray, + JObject jObject => jObject, + JToken token => token, + _ => new JValue(obj) + }; + return in2; + } + } +} diff --git a/ProtoFlux/JSON/JsonAppendToArray.cs b/ProtoFlux/JSON/JsonAppendToArray.cs new file mode 100644 index 0000000..36efd24 --- /dev/null +++ b/ProtoFlux/JSON/JsonAppendToArray.cs @@ -0,0 +1,40 @@ +using System; +using Newtonsoft.Json.Linq; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using FrooxEngine; +using Elements.Core; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + [NodeCategory("ProtoFlux/Obsidian/Json")] + [GenericTypes(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), + typeof(ulong), typeof(float), typeof(double), typeof(string), typeof(Uri), typeof(JToken), typeof(JObject), + typeof(JArray))] + public class JsonAppendToArray : ObjectFunctionNode + { + public readonly ObjectInput Array; + public readonly ObjectInput Object; + protected override JArray Compute(ExecutionContext context) + { + var array = Array.Evaluate(context); + var obj = Object.Evaluate(context); + if (array == null || obj == null) return null; + + try + { + var output = (JArray)array.DeepClone(); + output.Add(obj switch + { + JToken token => token, + _ => new JValue(obj) + }); + return output; + } + catch + { + return null; + } + } + } +} diff --git a/ProtoFlux/JSON/JsonCountArrayChildrenNode.cs b/ProtoFlux/JSON/JsonCountArrayChildrenNode.cs new file mode 100644 index 0000000..f364316 --- /dev/null +++ b/ProtoFlux/JSON/JsonCountArrayChildrenNode.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json.Linq; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + [NodeCategory("ProtoFlux/Obsidian/Json")] + public class JsonCountArrayChildrenNode : ValueFunctionNode + { + public readonly ObjectInput Input; + + protected override int Compute(ExecutionContext context) + { + var input = Input.Evaluate(context); + return input?.Count ?? -1; + } + } +} diff --git a/ProtoFlux/JSON/JsonCountObjectChildrenNode.cs b/ProtoFlux/JSON/JsonCountObjectChildrenNode.cs new file mode 100644 index 0000000..d03f660 --- /dev/null +++ b/ProtoFlux/JSON/JsonCountObjectChildrenNode.cs @@ -0,0 +1,18 @@ +using Newtonsoft.Json.Linq; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + [NodeCategory("ProtoFlux/Obsidian/Json")] + public class JsonCountObjectChildrenNode : ValueFunctionNode + { + public readonly ObjectInput Input; + + protected override int Compute(ExecutionContext context) + { + var input = Input.Evaluate(context); + return input?.Count ?? -1; + } + } +} diff --git a/ProtoFlux/JSON/JsonEmpty.cs b/ProtoFlux/JSON/JsonEmpty.cs new file mode 100644 index 0000000..fe3f9be --- /dev/null +++ b/ProtoFlux/JSON/JsonEmpty.cs @@ -0,0 +1,32 @@ +using Newtonsoft.Json.Linq; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + [NodeCategory("ProtoFlux/Obsidian/Json")] + public class JsonEmptyObjectNode : ObjectFunctionNode + { + protected override JObject Compute(ExecutionContext context) + { + return new JObject(); + } + } + + [NodeCategory("ProtoFlux/Obsidian/Json")] + public class JsonEmptyArrayNode : ObjectFunctionNode + { + protected override JArray Compute(ExecutionContext context) + { + return new JArray(); + } + } + [NodeCategory("ProtoFlux/Obsidian/Json")] + public class JsonNullValueNode : ObjectFunctionNode + { + protected override JToken Compute(ExecutionContext context) + { + return JValue.CreateNull(); + } + } +} \ No newline at end of file diff --git a/ProtoFlux/JSON/JsonGetFromArrayNode.cs b/ProtoFlux/JSON/JsonGetFromArrayNode.cs new file mode 100644 index 0000000..77f752c --- /dev/null +++ b/ProtoFlux/JSON/JsonGetFromArrayNode.cs @@ -0,0 +1,37 @@ +using System; +using Newtonsoft.Json.Linq; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using Elements.Core; +using FrooxEngine; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + [NodeCategory("ProtoFlux/obsidian/Json")] + [GenericTypes(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), + typeof(ulong), typeof(float), typeof(double), typeof(string), typeof(Uri), typeof(JToken), typeof(JObject), + typeof(JArray))] + public class JsonGetFromArrayNode : ObjectFunctionNode + { + public readonly ObjectInput Input; + public readonly ObjectInput Index; + + + protected override T Compute(ExecutionContext context) + { + var input = Input.Evaluate(context); + var index = Index.Evaluate(context); + if (input == null || index < 0 || index >= input.Count) + return default; + + try + { + return input[index].Value(); + } + catch + { + return default; + } + } + } +} diff --git a/ProtoFlux/JSON/JsonGetFromObject.cs b/ProtoFlux/JSON/JsonGetFromObject.cs new file mode 100644 index 0000000..5e5ac32 --- /dev/null +++ b/ProtoFlux/JSON/JsonGetFromObject.cs @@ -0,0 +1,36 @@ +using System; +using Newtonsoft.Json.Linq; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using Elements.Core; +using FrooxEngine; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + [NodeCategory("ProtoFlux/Obsidian/Json")] + [GenericTypes(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), + typeof(ulong), typeof(float), typeof(double), typeof(string), typeof(Uri), typeof(JToken), typeof(JObject), + typeof(JArray))] + public class JsonGetFromObjectNode : ObjectFunctionNode + { + public readonly ObjectInput Input; + public readonly ObjectInput Tag; + + protected override T Compute(ExecutionContext context) + { + var input = Input.Evaluate(context); + var tag = Tag.Evaluate(context); + if (input == null || string.IsNullOrEmpty(tag)) + return default; + + try + { + return input[tag].Value(); + } + catch + { + return default; + } + } + } +} diff --git a/ProtoFlux/JSON/JsonInfo.cs b/ProtoFlux/JSON/JsonInfo.cs new file mode 100644 index 0000000..47f60c6 --- /dev/null +++ b/ProtoFlux/JSON/JsonInfo.cs @@ -0,0 +1,27 @@ +using System; +using Newtonsoft.Json.Linq; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + public static class JsonInfo + { + public static readonly Type[] JsonTypes = + { + typeof(byte), + typeof(sbyte), + typeof(short), + typeof(ushort), + typeof(int), + typeof(uint), + typeof(long), + typeof(ulong), + typeof(float), + typeof(double), + typeof(string), + typeof(Uri), + typeof(JToken), + typeof(JObject), + typeof(JArray), + }; + } +} diff --git a/ProtoFlux/JSON/JsonInsertToArrayNode.cs b/ProtoFlux/JSON/JsonInsertToArrayNode.cs new file mode 100644 index 0000000..ff391b6 --- /dev/null +++ b/ProtoFlux/JSON/JsonInsertToArrayNode.cs @@ -0,0 +1,41 @@ +using System; +using Newtonsoft.Json.Linq; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using Elements.Core; +using FrooxEngine; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + [NodeCategory("ProtoFlux/Obsidian/Json")] + [GenericTypes(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), + typeof(ulong), typeof(float), typeof(double), typeof(string), typeof(Uri), typeof(JToken), typeof(JObject), + typeof(JArray))] + public class JsonInsertToArrayNode : ObjectFunctionNode + { + public readonly ObjectInput Array; + public readonly ObjectInput Object; + public readonly ObjectInput Index; + + protected override JArray Compute(ExecutionContext context) + { + var array = Array.Evaluate(context); + var obj = Object.Evaluate(context); + var index = Index.Evaluate(context); + if (array == null || obj == null || index < 0 || index > array.Count) + return null; + + try + { + var output = (JArray)array.DeepClone(); + JToken token = obj is JToken jToken ? jToken : new JValue(obj); + output.Insert(index, token); + return output; + } + catch + { + return null; + } + } + } +} diff --git a/ProtoFlux/JSON/JsonParseStringArray.cs b/ProtoFlux/JSON/JsonParseStringArray.cs new file mode 100644 index 0000000..0897898 --- /dev/null +++ b/ProtoFlux/JSON/JsonParseStringArray.cs @@ -0,0 +1,31 @@ +using System; +using Newtonsoft.Json.Linq; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + [NodeCategory("ProtoFlux/Obsidian/Json")] + public class JsonParseStringArrayNode : ObjectFunctionNode + { + public readonly ObjectInput Input; + + protected override JArray Compute(ExecutionContext context) + { + var input = Input.Evaluate(context); + if (string.IsNullOrEmpty(input)) + return null; + + try + { + var output = JArray.Parse(input); + return output; + } + catch + { + // In case of parsing error, return null + return null; + } + } + } +} diff --git a/ProtoFlux/JSON/JsonParseStringNode.cs b/ProtoFlux/JSON/JsonParseStringNode.cs new file mode 100644 index 0000000..8715ce7 --- /dev/null +++ b/ProtoFlux/JSON/JsonParseStringNode.cs @@ -0,0 +1,32 @@ +using System; +using Newtonsoft.Json.Linq; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + [NodeCategory("ProtoFlux/Obsidian/Json")] + public class JsonParseStringNode : ObjectFunctionNode + { + public readonly ObjectInput Input; + + + protected override JObject Compute(ExecutionContext context) + { + var input = Input.Evaluate(context); + if (string.IsNullOrEmpty(input)) + return null; + + try + { + var output = JObject.Parse(input); + return output; + } + catch + { + // In case of parsing error, return null + return null; + } + } + } +} diff --git a/ProtoFlux/JSON/JsonQuickGetObject.cs b/ProtoFlux/JSON/JsonQuickGetObject.cs new file mode 100644 index 0000000..aeaa2bd --- /dev/null +++ b/ProtoFlux/JSON/JsonQuickGetObject.cs @@ -0,0 +1,37 @@ +using System; +using Newtonsoft.Json.Linq; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using Elements.Core; +using FrooxEngine; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + [NodeCategory("ProtoFlux/Obsidian/Json")] + [GenericTypes(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), + typeof(ulong), typeof(float), typeof(double), typeof(string), typeof(Uri), typeof(JToken), typeof(JObject), + typeof(JArray))] + public class JsonQuickGetFromObjectNode : ObjectFunctionNode + { + public readonly ObjectInput Input; + public readonly ObjectInput Tag; + protected override T Compute(ExecutionContext context) + { + var input = Input.Evaluate(context); + var tag = Tag.Evaluate(context); + if (string.IsNullOrEmpty(input) || string.IsNullOrEmpty(tag)) + return default; + + try + { + var inputObject = JObject.Parse(input); + return inputObject[tag].Value() ?? default; + } + catch + { + // In case of parsing error or if the tag is not found + return default; + } + } + } +} diff --git a/ProtoFlux/JSON/JsonRemoveFromArrayNode.cs b/ProtoFlux/JSON/JsonRemoveFromArrayNode.cs new file mode 100644 index 0000000..5694273 --- /dev/null +++ b/ProtoFlux/JSON/JsonRemoveFromArrayNode.cs @@ -0,0 +1,35 @@ +using System; +using Newtonsoft.Json.Linq; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + [NodeCategory("ProtoFlux/Obsidian/Json")] + public class JsonRemoveFromArrayNode : ObjectFunctionNode + { + public readonly ObjectInput Array; + public readonly ObjectInput Index; + + + protected override JArray Compute(ExecutionContext context) + { + var array = Array.Evaluate(context); + var index = Index.Evaluate(context); + if (array == null || index < 0 || index >= array.Count) + return null; + + try + { + var output = (JArray)array.DeepClone(); + output.RemoveAt(index); + return output; + } + catch + { + // In case of an error, return null + return null; + } + } + } +} diff --git a/ProtoFlux/JSON/JsonRemoveFromObjectNode.cs b/ProtoFlux/JSON/JsonRemoveFromObjectNode.cs new file mode 100644 index 0000000..7ae2dd8 --- /dev/null +++ b/ProtoFlux/JSON/JsonRemoveFromObjectNode.cs @@ -0,0 +1,28 @@ +using System; +using Newtonsoft.Json.Linq; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + [NodeCategory("ProtoFlux/Obsidian/Json")] + public class JsonRemoveFromObjectNode : ObjectFunctionNode + { + public readonly ObjectInput Input; + public readonly ObjectInput Tag; + + + protected override JObject Compute(ExecutionContext context) + { + var input = Input.Evaluate(context); + if (input == null) return null; + + var tag = Tag.Evaluate(context); + if (string.IsNullOrEmpty(tag)) return input; + + var output = (JObject)input.DeepClone(); + output.Remove(tag); + return output; + } + } +} diff --git a/ProtoFlux/JSON/JsonToStringNode.cs b/ProtoFlux/JSON/JsonToStringNode.cs new file mode 100644 index 0000000..a6728dd --- /dev/null +++ b/ProtoFlux/JSON/JsonToStringNode.cs @@ -0,0 +1,21 @@ +using System; +using FrooxEngine; +using Newtonsoft.Json.Linq; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json +{ + [NodeCategory("ProtoFlux/Obsidian/Json")] + [GenericTypes(typeof(JToken), typeof(JObject), typeof(JArray))] + public class JsonToStringNode : ObjectFunctionNode where T : JToken + { + public readonly ObjectInput Input; + + protected override string Compute(ExecutionContext context) + { + var input = Input.Evaluate(context); + return input?.ToString(); + } + } +}