Replace A with B


Node Information
Replaces given value with the given value in the string.
General Information
• This node doesn't have other available options.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Text IN String ONE FALSE FALSE
A IN String ONE FALSE FALSE
B IN String ONE FALSE FALSE
Result OUT String MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.String
{
    [IsNode("Replace")]
    public class StringReplace : Node
    {
        Port str = new Port(PortType.IN, typeof(string), AcceptsLinks.ONE, "Text");
        Port a = new Port(PortType.IN, typeof(string), AcceptsLinks.ONE, "A");
        Port b = new Port(PortType.IN, typeof(string), AcceptsLinks.ONE, "B");
        Port res = new Port(PortType.OUT, typeof(string), AcceptsLinks.MULTIPLE, "Result");
        public string A
        {
            set { a.Value = value; }
            get { return GetRuntimeValue(a); }
        }
        public string B
        {
            set { b.Value = value; }
            get { return GetRuntimeValue(b); }
        }
        public StringReplace()
        {
            NodeType = KGraph.NodeType.Function;
            ReturnType = typeof(string);
            Name = "Replace A with B";
            AddPort(str);
            AddPort(a);
            AddPort(b);
            AddPort(res);
            Information = "Replaces given value with the given value in the string.";
        }
        public override string Code()
        {
            return "return (" + GetValue(str) + ").Replace(" + GetValue(a) + "," + GetValue(b) + ");";
        }
    }
}