mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
added string lLength and IsNullOrEmpty nodes
This commit is contained in:
parent
f96bf05820
commit
e54e791062
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("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<string>();
|
||||
Result = CreateOutputPin<Numeric>();
|
||||
}
|
||||
|
||||
public InputPin<string> Input1 { get; }
|
||||
|
||||
public OutputPin<Numeric> Result { get; }
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
Result.Value = new Numeric((Input1.Value ?? "").Length);
|
||||
}
|
||||
}
|
||||
29
src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs
Normal file
29
src/Artemis.VisualScripting/Nodes/Text/StrıngNullOrEmpty.cs
Normal file
@ -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<string>();
|
||||
TrueResult = CreateOutputPin<bool>("true (Empty)");
|
||||
FalseResult = CreateOutputPin<bool>("false (Not Empty)");
|
||||
}
|
||||
|
||||
public InputPin<string> Input1 { get; }
|
||||
|
||||
public OutputPin<bool> TrueResult { get; }
|
||||
|
||||
public OutputPin<bool> FalseResult { get; }
|
||||
|
||||
public override void Evaluate()
|
||||
{
|
||||
bool isNullOrWhiteSpace = string.IsNullOrWhiteSpace(Input1.Value);
|
||||
TrueResult.Value = isNullOrWhiteSpace;
|
||||
FalseResult.Value = !isNullOrWhiteSpace;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user