From e54e791062613683dbbfb1420761dd511a74a219 Mon Sep 17 00:00:00 2001 From: "aytac.kayadelen" Date: Wed, 24 Aug 2022 11:15:29 +0300 Subject: [PATCH 1/5] added string lLength and IsNullOrEmpty nodes --- .../Nodes/Text/StringLengthNode.cs | 24 +++++++++++++++ .../Nodes/Text/StrıngNullOrEmpty.cs | 29 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs create mode 100644 src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs diff --git a/src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs b/src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs new file mode 100644 index 000000000..f6a09ef66 --- /dev/null +++ b/src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs @@ -0,0 +1,24 @@ +using Artemis.Core; + +namespace Artemis.VisualScripting.Nodes.Text; + +[Node("String Length", "Checks whether the first input is contained in the second input.", + "Text", InputType = typeof(string), OutputType = typeof(Numeric))] +public class StringLengthNode : Node +{ + public StringLengthNode() + : base("String Length", "Returns string length.") + { + Input1 = CreateInputPin(); + Result = CreateOutputPin(); + } + + public InputPin Input1 { get; } + + public OutputPin Result { get; } + + public override void Evaluate() + { + Result.Value = new Numeric((Input1.Value ?? "").Length); + } +} \ No newline at end of file diff --git a/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs b/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs new file mode 100644 index 000000000..7dd6b1d0b --- /dev/null +++ b/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs @@ -0,0 +1,29 @@ +using Artemis.Core; + +namespace Artemis.VisualScripting.Nodes.Text; + +[Node("String Null or WhiteSpace", "Checks whether the string is null or white space.", + "Text", InputType = typeof(string), OutputType = typeof(bool))] +public class StringNullOrWhiteSpaceNode : Node +{ + public StringNullOrWhiteSpaceNode() + : base("Null or White Space", "Returns true if null or white space") + { + Input1 = CreateInputPin(); + TrueResult = CreateOutputPin("true (Empty)"); + FalseResult = CreateOutputPin("false (Not Empty)"); + } + + public InputPin Input1 { get; } + + public OutputPin TrueResult { get; } + + public OutputPin FalseResult { get; } + + public override void Evaluate() + { + bool isNullOrWhiteSpace = string.IsNullOrWhiteSpace(Input1.Value); + TrueResult.Value = isNullOrWhiteSpace; + FalseResult.Value = !isNullOrWhiteSpace; + } +} \ No newline at end of file From a92c0adaf4b7d41a528a5f36743cb5e42dba8667 Mon Sep 17 00:00:00 2001 From: "aytac.kayadelen" Date: Wed, 24 Aug 2022 12:02:26 +0300 Subject: [PATCH 2/5] update output namings --- .../Nodes/Text/StrıngNullOrEmpty.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs b/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs index 7dd6b1d0b..df1f5ee65 100644 --- a/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs +++ b/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs @@ -2,7 +2,7 @@ namespace Artemis.VisualScripting.Nodes.Text; -[Node("String Null or WhiteSpace", "Checks whether the string is null or white space.", +[Node("String Null or WhiteSpace", "Checks whether the string is null, empty or white space.", "Text", InputType = typeof(string), OutputType = typeof(bool))] public class StringNullOrWhiteSpaceNode : Node { @@ -10,20 +10,20 @@ public class StringNullOrWhiteSpaceNode : Node : base("Null or White Space", "Returns true if null or white space") { Input1 = CreateInputPin(); - TrueResult = CreateOutputPin("true (Empty)"); - FalseResult = CreateOutputPin("false (Not Empty)"); + NullOrWhiteSpaceResult = CreateOutputPin("White Space"); + HasContentResult = CreateOutputPin("Has Content"); } public InputPin Input1 { get; } - public OutputPin TrueResult { get; } + public OutputPin NullOrWhiteSpaceResult { get; } - public OutputPin FalseResult { get; } + public OutputPin HasContentResult { get; } public override void Evaluate() { bool isNullOrWhiteSpace = string.IsNullOrWhiteSpace(Input1.Value); - TrueResult.Value = isNullOrWhiteSpace; - FalseResult.Value = !isNullOrWhiteSpace; + NullOrWhiteSpaceResult.Value = isNullOrWhiteSpace; + HasContentResult.Value = !isNullOrWhiteSpace; } } \ No newline at end of file From 37f544a9c1f66f7cdfbcf86afaff88916d13b4cc Mon Sep 17 00:00:00 2001 From: "aytac.kayadelen" Date: Wed, 24 Aug 2022 13:12:00 +0300 Subject: [PATCH 3/5] simplify node output names --- src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs b/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs index df1f5ee65..705946cdb 100644 --- a/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs +++ b/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs @@ -10,8 +10,8 @@ public class StringNullOrWhiteSpaceNode : Node : base("Null or White Space", "Returns true if null or white space") { Input1 = CreateInputPin(); - NullOrWhiteSpaceResult = CreateOutputPin("White Space"); - HasContentResult = CreateOutputPin("Has Content"); + NullOrWhiteSpaceResult = CreateOutputPin("true"); + HasContentResult = CreateOutputPin("false"); } public InputPin Input1 { get; } From 2e5977b55f530278a2b1c283849cc884fd6b670a Mon Sep 17 00:00:00 2001 From: "aytac.kayadelen" Date: Thu, 25 Aug 2022 10:17:54 +0300 Subject: [PATCH 4/5] omit "string" from descriptions --- .../Nodes/Text/StringLengthNode.cs | 6 ++-- .../Nodes/Text/StringNullOrEmptyNode.cs | 25 ++++++++++++++++ .../Nodes/Text/StrıngNullOrEmpty.cs | 29 ------------------- 3 files changed, 28 insertions(+), 32 deletions(-) create mode 100644 src/Artemis.VisualScripting/Nodes/Text/StringNullOrEmptyNode.cs delete mode 100644 src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs diff --git a/src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs b/src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs index f6a09ef66..421ad4dec 100644 --- a/src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs +++ b/src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs @@ -2,12 +2,12 @@ namespace Artemis.VisualScripting.Nodes.Text; -[Node("String Length", "Checks whether the first input is contained in the second input.", +[Node("Text Length", "Outputs the length of the input text.", "Text", InputType = typeof(string), OutputType = typeof(Numeric))] public class StringLengthNode : Node { public StringLengthNode() - : base("String Length", "Returns string length.") + : base("Text Length", "Outputs text length.") { Input1 = CreateInputPin(); Result = CreateOutputPin(); @@ -19,6 +19,6 @@ public class StringLengthNode : Node public override void Evaluate() { - Result.Value = new Numeric((Input1.Value ?? "").Length); + Result.Value = Input1.Value == null ? new Numeric(0) : new Numeric(Input1.Value.Length); } } \ No newline at end of file diff --git a/src/Artemis.VisualScripting/Nodes/Text/StringNullOrEmptyNode.cs b/src/Artemis.VisualScripting/Nodes/Text/StringNullOrEmptyNode.cs new file mode 100644 index 000000000..80db0442c --- /dev/null +++ b/src/Artemis.VisualScripting/Nodes/Text/StringNullOrEmptyNode.cs @@ -0,0 +1,25 @@ +using Artemis.Core; + +namespace Artemis.VisualScripting.Nodes.Text; + +[Node("Text is empty", "Outputs true if the input text is empty, false if it contains any text.", + "Text", InputType = typeof(string), OutputType = typeof(bool))] +public class StringNullOrEmptyNode : Node +{ + public StringNullOrEmptyNode() + : base("Text is empty", "Outputs true if empty") + { + Input1 = CreateInputPin(); + Output1 = CreateOutputPin("true"); + } + + public InputPin Input1 { get; } + + public OutputPin Output1 { get; } + + public override void Evaluate() + { + bool isNullOrWhiteSpace = string.IsNullOrWhiteSpace(Input1.Value); + Output1.Value = isNullOrWhiteSpace; + } +} \ No newline at end of file diff --git a/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs b/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs deleted file mode 100644 index 705946cdb..000000000 --- a/src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Artemis.Core; - -namespace Artemis.VisualScripting.Nodes.Text; - -[Node("String Null or WhiteSpace", "Checks whether the string is null, empty or white space.", - "Text", InputType = typeof(string), OutputType = typeof(bool))] -public class StringNullOrWhiteSpaceNode : Node -{ - public StringNullOrWhiteSpaceNode() - : base("Null or White Space", "Returns true if null or white space") - { - Input1 = CreateInputPin(); - NullOrWhiteSpaceResult = CreateOutputPin("true"); - HasContentResult = CreateOutputPin("false"); - } - - public InputPin Input1 { get; } - - public OutputPin NullOrWhiteSpaceResult { get; } - - public OutputPin HasContentResult { get; } - - public override void Evaluate() - { - bool isNullOrWhiteSpace = string.IsNullOrWhiteSpace(Input1.Value); - NullOrWhiteSpaceResult.Value = isNullOrWhiteSpace; - HasContentResult.Value = !isNullOrWhiteSpace; - } -} \ No newline at end of file From ce1cf948ce5a1fcd532f0ecd07e0802c331f9f0c Mon Sep 17 00:00:00 2001 From: "aytac.kayadelen" Date: Thu, 25 Aug 2022 14:08:22 +0300 Subject: [PATCH 5/5] remove 'Text Empty' node output name --- src/Artemis.VisualScripting/Nodes/Text/StringNullOrEmptyNode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Artemis.VisualScripting/Nodes/Text/StringNullOrEmptyNode.cs b/src/Artemis.VisualScripting/Nodes/Text/StringNullOrEmptyNode.cs index 80db0442c..6c80e372f 100644 --- a/src/Artemis.VisualScripting/Nodes/Text/StringNullOrEmptyNode.cs +++ b/src/Artemis.VisualScripting/Nodes/Text/StringNullOrEmptyNode.cs @@ -10,7 +10,7 @@ public class StringNullOrEmptyNode : Node : base("Text is empty", "Outputs true if empty") { Input1 = CreateInputPin(); - Output1 = CreateOutputPin("true"); + Output1 = CreateOutputPin(); } public InputPin Input1 { get; }