List Items Count


Node Information
Gets item count of the specified List.
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
IN List<Object> ONE TRUE TRUE
Value OUT Int32 MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.List
{
    [IsNode("Items Count")]
    public class ListItemsCount : Node
    {
        Port list = new Port(PortType.IN, typeof(List<object>), AcceptsLinks.ONE);
        Port val = new Port(PortType.OUT, typeof(int), AcceptsLinks.MULTIPLE, "Value");
        public ListItemsCount()
        {
            this.Name = "List Items Count";
            AddPort(list);
            AddPort(val);
            val.Instructions = "init";
            Information = "Gets item count of the specified List.";
            list.CustomAcception = Accepts;
        }
        public override void UpdateResults()
        {
            val.Instructions = GetValue(list) + ".Count";
        }
        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;
                return true;
            }
            return false;
        }
    }
}

</object>