String Sort Characters


Node Information
Sorts the characters in the given text in alphabetical order, the result will be fed to 'Result' port.
General Information
• This node doesn't have other available options.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Text IN String ONE FALSE FALSE
Result OUT String MULTIPLE FALSE FALSE
RemoveDuplicates IN Boolean ONE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.String
{
    [IsNode("Sort Characters")]
    public class StringSortCharacters : Node
    {
        Port a = new Port(PortType.IN, typeof(string), AcceptsLinks.ONE, "Text");
        Port re = new Port(PortType.IN, typeof(bool), AcceptsLinks.ONE, "RemoveDuplicates");
        Port res = new Port(PortType.OUT, typeof(string), AcceptsLinks.MULTIPLE, "Result");
        public bool RemoveDuplicates
        {
            set { re.Value = value.ToString(); }
            get { return GetRuntimeValue(re); }
        }
        public string Text
        {
            set { a.Value = value; }
            get { return GetRuntimeValue(a); }
        }
        public StringSortCharacters()
        {
            NodeType = NodeType.Function;
            ReturnType = typeof(string);
            Name = "String Sort Characters";
            AddPort(a);
            AddPort(res);
            AddPort(re);
            Information = "Sorts the characters in the given text in alphabetical order, the result will be fed to 'Result' port.";
        }
        public override string Code()
        {
            string removedup = string.Empty;
            if (RemoveDuplicates)
            {
                removedup = ".Distinct()";
            }
            return "return string.Concat(" + GetValue(a) + ".OrderBy(a => a)" + removedup + ");";
        }
    }
}