using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using FileFlows.Plugin;
using FileFlows.Plugin.Attributes;
namespace FileFlows.BasicNodes.Functions;
///
/// A node that choose a random output
///
public class Random : Node
{
///
/// Gets the number of input nodes
///
public override int Inputs => 1;
///
/// Gets or sets the number of outputs
///
[DefaultValue(3)]
[NumberInt(1)]
[Range(2, 10)]
public new int Outputs { get; set; }
///
/// Gets the type of node
///
public override FlowElementType Type => FlowElementType.Logic;
///
/// Gets the icon of the flow
///
public override string Icon => "fas fa-dice";
///
/// Gets the URL for the help page
///
public override string HelpUrl => "https://fileflows.com/docs/plugins/basic-nodes/random";
///
/// Executes the node
///
/// the node parameters
/// -1 to indicate the flow should fail
public override int Execute(NodeParameters args)
{
var rand = new System.Random(DateTime.UtcNow.Millisecond);
int output = rand.Next(1, Outputs + 1);
args.Logger?.ILog("Random output selected: " + output);
return output;
}
}