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:
commit
87b87a9145
24
src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs
Normal file
24
src/Artemis.VisualScripting/Nodes/Text/StringLengthNode.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user