1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Merge pull request #718 from Aytackydln/master

Added String Length and IsNullOrWhiteSpace Nodes
This commit is contained in:
RobertBeekman 2022-08-26 20:18:24 +02:00 committed by GitHub
commit 87b87a9145
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,24 @@
using Artemis.Core;
namespace Artemis.VisualScripting.Nodes.Text;
[Node("Text Length", "Outputs the length of the input text.",
"Text", InputType = typeof(string), OutputType = typeof(Numeric))]
public class StringLengthNode : Node
{
public StringLengthNode()
: base("Text Length", "Outputs text length.")
{
Input1 = CreateInputPin<string>();
Result = CreateOutputPin<Numeric>();
}
public InputPin<string> Input1 { get; }
public OutputPin<Numeric> Result { get; }
public override void Evaluate()
{
Result.Value = Input1.Value == null ? new Numeric(0) : new Numeric(Input1.Value.Length);
}
}

View File

@ -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<string>();
Output1 = CreateOutputPin<bool>();
}
public InputPin<string> Input1 { get; }
public OutputPin<bool> Output1 { get; }
public override void Evaluate()
{
bool isNullOrWhiteSpace = string.IsNullOrWhiteSpace(Input1.Value);
Output1.Value = isNullOrWhiteSpace;
}
}