using NodePipeline.Abstractions.Interfaces.Nodes;

namespace NodePipeline.Engine.Utils;

public static class NodeFieldCodeGenerator
{
    public static string GenerateFieldCode(string nodeId, string name, FieldDirection direction)
    {
        var prefix = FieldDirectionToString(direction);
        return string.Concat(prefix.ToUpper(), "_", nodeId, ".", name);
    }

    private static string FieldDirectionToString(FieldDirection direction)
    {
        return direction switch
        {
            FieldDirection.Input => "in",
            FieldDirection.Output => "out",
            FieldDirection.Parameter => "param",
            _ => throw new ArgumentOutOfRangeException(nameof(direction), direction, null)
        };
    }
}