Read File All


Node Information
Reads the specified file as text.
General Information
• This node doesn't have other available options.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Path IN String ONE FALSE FALSE
Content OUT String MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.IO.File
{
    [IsNode("Read File All")]
    public class FileReadAll : Node
    {
        Port path = new Port(PortType.IN, typeof(string), AcceptsLinks.ONE, "Path");
        Port content = new Port(PortType.OUT, typeof(string), AcceptsLinks.MULTIPLE, "Content");
        public string FilePath
        {
            set { path.Value = value.ToString(); }
            get { return GetRuntimeValue(path); }
        }
        public FileReadAll()
        {
            this.Name = "Read File All";
            this.NodeType = KGraph.NodeType.Function;
            this.ReturnType = typeof(string);
            AddPort(path);
            AddPort(content);
            Information = "Reads the specified file as text.";
        }
        public override string Code()
        {
            string filepath = string.Empty;
            if (path.IsConnected) { filepath = GetValue(path); }
            else { filepath = "@" + q + FilePath + q; }
            string code = "return System.IO.File.ReadAllText(" + filepath + ");";
            return code;
        }
    }
}