You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.0 KiB
36 lines
1.0 KiB
using System.Text.Json.Serialization; |
|
using StabilityMatrix.Core.Models.Api.Comfy.NodeTypes; |
|
|
|
namespace StabilityMatrix.Core.Models.Api.Comfy.Nodes; |
|
|
|
[JsonSerializable(typeof(NamedComfyNode))] |
|
public record NamedComfyNode([property: JsonIgnore] string Name) : ComfyNode, IOutputNode |
|
{ |
|
/// <summary> |
|
/// Returns { Name, index } for use as a node connection |
|
/// </summary> |
|
public object[] GetOutput(int index) |
|
{ |
|
return new object[] { Name, index }; |
|
} |
|
|
|
/// <summary> |
|
/// Returns typed { Name, index } for use as a node connection |
|
/// </summary> |
|
public TOutput GetOutput<TOutput>(int index) where TOutput : NodeConnectionBase, new() |
|
{ |
|
return new TOutput |
|
{ |
|
Data = GetOutput(index) |
|
}; |
|
} |
|
} |
|
|
|
[JsonSerializable(typeof(NamedComfyNode<>))] |
|
public record NamedComfyNode<TOutput>(string Name) : NamedComfyNode(Name) where TOutput : NodeConnectionBase, new() |
|
{ |
|
public TOutput Output => new TOutput |
|
{ |
|
Data = GetOutput(0) |
|
}; |
|
}
|
|
|