IsNull Expression


Node Information
Checks the given value, if it's Null result will be TRUE, else result will be FALSE.
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
A IN Object ONE FALSE TRUE
Result OUT Boolean MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.Conditions
{
    [IsNode("IsNull Expression")]
    public class IsNullExpression : Node
    {
        Port a = new Port(PortType.IN, typeof(object), AcceptsLinks.ONE, "A");
        Port result = new Port(PortType.OUT, typeof(bool), AcceptsLinks.MULTIPLE, "Result");
        public IsNullExpression()
        {
            NodeType = NodeType.Function;
            ReturnType = typeof(bool);
            this.Name = "IsNull Expression";
            this.AddPort(a);
            this.AddPort(result);
            a.CustomAcception = Accepts;
            Information = "Checks the given value, if it's Null result will be TRUE, else result will be FALSE.";
        }
        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" + ") { return true; } else { return false; }";
            }
            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.";
            }
        }
    }
}