Enum Names


Node Information
Gets all the names of the enum type.
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
Enum IN Object ONE FALSE TRUE
Names OUT List<String> MULTIPLE TRUE FALSE

Source
namespace Korduene.KGraph.Nodes.Utilities
{
    [IsNode("Get Enum Names")]
    public class GetEnumNames : Node
    {
        Port enu = new Port(PortType.IN, typeof(object), AcceptsLinks.ONE, "Enum");
        Port names = new Port(PortType.OUT, typeof(List<string>), AcceptsLinks.MULTIPLE, "Names");
        public GetEnumNames()
        {
            this.Name = "Enum Names";
            NodeType = NodeType.Function;
            AddPort(enu);
            AddPort(names);
            ReturnType = typeof(List<string>);
            enu.EditorEnabled = false;
            enu.CustomAcception = Accept;
            Information = "Gets all the names of the enum type.";
        }
        bool Accept(Port port)
        {
            if (port == null)
            {
                return false;
            }
            if (enu.IsConnected)
            {
                return false;
            }
            if (port.DataType != null && port.DataType.IsEnum)
            {
                enu.DataType = port.DataType;
                return true;
            }
            return false;
        }
        public override string Code()
        {
            string code = string.Empty;
            if (enu.IsConnected)
            {
                code = "return Enum.GetNames(typeof(" + enu.DataType.FullName + ")).ToList();";
            }
            return code;
        }
    }
}