Size Converter


Node Information
Converts file size in bytes to a readable file size.
General Information
• This node doesn't have other available options.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Variable IN Int64 ONE FALSE FALSE
Result OUT String MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.Utilities
{
    [IsNode("Size Converter")]
    public class FileSizeConverter : Node
    {
        Port variable = new Port(PortType.IN, typeof(long), AcceptsLinks.ONE, "Variable");
        Port result = new Port(PortType.OUT, typeof(string), AcceptsLinks.MULTIPLE, "Result");
        public long Value
        {
            set
            {
                variable.Value = value.ToString();
            }
            get
            {
                return GetRuntimeValue(variable);
            }
        }
        public FileSizeConverter()
        {
            Name = "Size Converter";
            NodeType = KGraph.NodeType.Function;
            ReturnType = typeof(string);
            AddPort(variable);
            AddPort(result);
            Information = "Converts file size in bytes to a readable file size.";
        }
        public override string Code()
        {
            return "return FileSizeConverter.ConvertSize(" + GetValue(variable) + ");";
        }
    }
}