using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
namespace FileFlows.BasicNodes.FileProperties;
///
/// Flow element that tests if a file property exists
///
public class FilePropertyExists : Node
{
///
public override int Inputs => 1;
///
public override int Outputs => 2;
///
public override FlowElementType Type => FlowElementType.Process;
///
public override string Icon => "fas fa-question";
///
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/file-property-exists";
///
/// Gets or sets the property name
///
[TextVariable(1)]
public string Property { get; set; }
///
public override int Execute(NodeParameters args)
{
string property = args.ReplaceVariables(this.Property ?? string.Empty, stripMissing: true);
if (string.IsNullOrEmpty(property))
return args.Fail("No property set");
string actualValue = args.GetProperty(property);
bool exists = string.IsNullOrWhiteSpace(actualValue) == false;
args.Logger?.ILog(exists ? "Property exists" : "Property does not exist");
return exists ? 1 : 2;
}
}