public string Input(int index = 0)
{
string path;
if (inputCache.TryGetValue(index, out path))
return path;
if (index < 0 || index >= inputs.Length)
{
instance.Log.Error("Index of Input ({0}) given to Run() is outside the bounds of available inputs ({1}). ('{2}' on line {3})", index, inputs.Length, instance.OutputName, lineNumber);
return "<Error>";
}
var stream = inputs[index] as Stream;
if (stream == null)
{
instance.Log.Error("Input to Run() node must be of type stream ('{0}' on line {1}).", instance.OutputName, lineNumber);
return "<Error>";
}
var file = stream as FileStream;
if (file != null)
return file.Name;
// otherwise, we need to write to a temporary file
path = Path.GetTempFileName();
using (var tempFile = File.Create(path))
stream.CopyTo(tempFile);
inputCache[index] = path;
return path;
}