using System.ComponentModel;
using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
namespace FileFlows.BasicNodes.Conditions;
///
/// A flow element that test if a string matches another string
///
public class IfString: IfBase
{
///
/// Gets or sets the URL to the help page
///
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/conditions/if-string";
///
/// Gets the number of outputs
///
[DefaultValue(2)]
[NumberInt(2)]
public new int Outputs { get; set; }
///
/// Gets or sets the options the variable can match
///
[StringArray(3)]
public string[] Options { get; set; }
///
/// Checks the variable value
///
/// the node parameters
/// the variable value
/// true if matches, otherwise false
protected override int DoCheck(NodeParameters args, object value)
{
if (Options?.Any() != true) return -1;
var index = Options.ToList().FindIndex(x => x == value as string);
if (index > 0)
return index + 1;
return index;
}
}