Add To List


Node Information
Adds value to the specified list. Click the info button to specify the type, then attach the list to 'List', attach the value you want to add, then call 'Add'.
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
Add IN RUN MULTIPLE FALSE FALSE
List IN List<Object> ONE TRUE TRUE
Value IN Object ONE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.List
{
    [IsNode("Add To List")]
    public class ListAdd : Node
    {
        Port run = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Add");
        Port get = new Port(PortType.IN, typeof(object), AcceptsLinks.ONE, "Value");
        Port list = new Port(PortType.IN, typeof(List<object>), AcceptsLinks.ONE, "List");
        public ListAdd()
        {
            this.Name = "Add To List";
            this.NodeType = NodeType.Method;
            AddPort(run);
            AddPort(list);
            AddPort(get);
            list.CustomAcception = Accepts;
            Information = "Adds value to the specified list. " +
                "Click the info button to specify the type, then attach the list to 'List', " +
                "attach the value you want to add, then call 'Add'.";
        }
        private bool Accepts(Port port)
        {
            if (port == null)
            {
                return false;
            }
            if (list.IsConnected)
            {
                return false;
            }
            if (port.DataType != null && port.IsList)
            {
                list.DataType = port.DataType;
                get.DataType = GraphCore.GetListSubType(port.DataType);
                return true;
            }
            return false;
        }
        public override string Code()
        {
            return GetValue(list) + ".Add(" + GetValue(get) + ");";
        }
    }
}

</object>