IsNull


Node Information
Checks the given value, if it's Null True will be called, else False Will be called.
General Information
• This node doesn't have other available options.
• Some of the ports of this node can change their types and accept types automatically.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Check IN RUN MULTIPLE FALSE FALSE
A IN Object ONE FALSE TRUE
True OUT RUN MULTIPLE FALSE FALSE
False OUT RUN MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.Conditions
{
    [IsNode("IsNull")]
    public class IsNull : Node
    {
        Port chk = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Check");
        Port a = new Port(PortType.IN, typeof(object), AcceptsLinks.ONE, "A");
        Port tr = new Port(PortType.OUT, typeof(RUN), AcceptsLinks.MULTIPLE, "True");
        Port fl = new Port(PortType.OUT, typeof(RUN), AcceptsLinks.MULTIPLE, "False");
        public IsNull()
        {
            NodeType = NodeType.Method;
            Name = "IsNull";
            AddPort(chk);
            AddPort(a);
            AddPort(tr);
            AddPort(fl);
            Information = "Checks the given value, if it's Null True will be called, else False Will be called.";
            a.CustomAcception = Accepts;
        }
        private bool Accepts(Port port)
        {
            if (port != null && port.DataType != null)
            {
                a.DataType = port.DataType;
                return true;
            }
            return false;
        }
        public override string Code()
        {
            if (a.IsConnected)
            {
                return "if (" + GetValue(a) + " == null) { " + GetValue(tr) + " } else { " + GetValue(fl) + " }";
            }
            return string.Empty;
        }
        public override void UpdateResults()
        {
            if (a.IsConnected)
            {
                IsInfoMenuEnabled = false;
                Status = NodeStatus.OK;
                ErrorMessage = string.Empty;
            }
            else
            {
                IsInfoMenuEnabled = true;
                Status = NodeStatus.ERROR;
                ErrorMessage = "Not all variables attached.";
            }
        }
    }
}