diff --git a/ComfySharp/NodeDBGenerator.cs b/ComfySharp/NodeDBGenerator.cs index fd2e360..50f0f24 100644 --- a/ComfySharp/NodeDBGenerator.cs +++ b/ComfySharp/NodeDBGenerator.cs @@ -12,6 +12,7 @@ namespace ComfySharp; public class NodeDBGenerator { readonly private List nodes; + #region Conversion readonly private ConversionSettings settings; @@ -140,13 +141,21 @@ public class NodeDBGenerator { foreach (var knownEnum in knownEnums) { GenerateEnum(knownEnum.Key, knownEnum.Value, enumNs); } - GenerateEnum("BaseTypes", knownTypes, enumNs);//TODO: make a proper method that handles the edge cases, like * and comma separated multi instances + //TODO: make a proper method that handles the edge cases, like * and comma separated multi instances + //GenerateEnum("BaseTypes", knownTypes, enumNs); + + compileUnit.Namespaces.Remove(enumNs); Logger.Info($"Enum Generation finished. Took {timer.ElapsedMilliseconds} ms"); + + Logger.Info("Classes Generation starting..."); timer.Restart(); - //compileUnit.Namespaces.Add(codeNamespace); - //ns.Imports.AddRange(new CodeNamespaceImport[] { new ("System"), new ("System.Collections.Generics"), new ("ComfySharp") }); + compileUnit.Namespaces.Add(codeNamespace); + codeNamespace.Imports.AddRange(new CodeNamespaceImport[] { new ("System"), new ("System.Collections.Generics"), new ("ComfySharp") }); + } + + private void GenerateEnum(string name, List enumValues, CodeNamespace ns) { string path = Path.Combine(Environment.CurrentDirectory, settings.CodeOutputFolderName, $"{name}.cs"); Logger.Debug($"Generating enum {name} w\\ {enumValues.Count} values.\n" + diff --git a/ComfySharp/Types/IInput.cs b/ComfySharp/Types/IInput.cs new file mode 100644 index 0000000..e8f9810 --- /dev/null +++ b/ComfySharp/Types/IInput.cs @@ -0,0 +1,5 @@ +namespace ComfySharp.Types; + +public interface IInput { + +} \ No newline at end of file diff --git a/ComfySharp/Types/INode.cs b/ComfySharp/Types/INode.cs new file mode 100644 index 0000000..1ea2064 --- /dev/null +++ b/ComfySharp/Types/INode.cs @@ -0,0 +1,30 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; + +namespace ComfySharp.Types; + +public interface INode { + //Inputs + [DataMember(Name = "input")] + public Inputs Inputs { get; } + //Outputs + [DataMember(Name = "output")] + public string[] Outputs { get; } + [DataMember(Name = "output_is_list")] + public bool[] OutputIsList { get; } + [DataMember(Name = "output_name")] + public string[] OutputNames { get; } + //Metadata + [DataMember(Name = "name")] + public string Name { get; } + [DataMember(Name = "display_name")] + public string DisplayName { get; } + [DataMember(Name = "description")] + public string Description { get; } + [DataMember(Name = "category")] + public string Category { get; } + [DataMember(Name = "output_node")] + public bool IsOutputNode { get; } + + +} \ No newline at end of file diff --git a/ComfySharp/Types/Input.cs b/ComfySharp/Types/Input.cs deleted file mode 100644 index a19213d..0000000 --- a/ComfySharp/Types/Input.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Runtime.Serialization; - -namespace ComfySharp.Types; - -[DataContract] -public struct Input { - [DataMember] - public List Required { get; set; } - [DataMember] - public List Optional { get; set; } - [DataMember] - public List Hidden { get; set; } - - public Input() { - Required = new(); - Optional = new(); - Hidden = new(); - } -} \ No newline at end of file diff --git a/ComfySharp/Types/InputField.cs b/ComfySharp/Types/InputField.cs index 2979db8..4944d93 100644 --- a/ComfySharp/Types/InputField.cs +++ b/ComfySharp/Types/InputField.cs @@ -1,10 +1,17 @@ using System.Runtime.Serialization; +using System.Text.Json.Serialization; namespace ComfySharp.Types; -public struct InputField { - [DataMember(Name = "name")] +[DataContract, JsonSerializable(typeof(InputField))] +public class InputField : IInput { + [DataMember(Name = "name", IsRequired = false)] public string Name { get; set; } - - public PrimitiveType Type { get; set; } + [DataMember(Name = "type", IsRequired = false)] + public string Type { get; set; } + + public InputField(string name, string type) { + Name = name; + Type = type; + } } \ No newline at end of file diff --git a/ComfySharp/Types/Inputs.cs b/ComfySharp/Types/Inputs.cs new file mode 100644 index 0000000..2196655 --- /dev/null +++ b/ComfySharp/Types/Inputs.cs @@ -0,0 +1,14 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; + +namespace ComfySharp.Types; + +[DataContract, JsonSerializable(typeof(Inputs))] +public class Inputs { + [DataMember(Name = "required")] + public List Required { get; set; } = new(); + [DataMember(Name = "optional", IsRequired = false)] + public List? Optional { get; set; } + [DataMember(Name = "hidden", IsRequired = false)] + public List? Hidden { get; set; } +} \ No newline at end of file diff --git a/ComfySharp/Types/Node.cs b/ComfySharp/Types/Node.cs index 011b0d4..f0080f6 100644 --- a/ComfySharp/Types/Node.cs +++ b/ComfySharp/Types/Node.cs @@ -8,9 +8,9 @@ public class Node { [DataMember(Name = "name")] public string Name { get; set; } [DataMember(Name = "input")] - public Input Input { get; set; } + public Inputs Inputs { get; set; } [DataMember(Name = "output")] - public List Outputs { get; set; } + public List Outputs { get; set; } [DataMember(Name = "output_is_list")] public List OutputIsList { get; set; } [DataMember(Name = "output_name")] @@ -26,7 +26,7 @@ public class Node { public Node() { Name = ""; - Input = new(); + Inputs = new(); Outputs = new(); OutputIsList = new(); OutputNames = new(); diff --git a/ComfySharp/Types/PrimitiveType.cs b/ComfySharp/Types/PrimitiveType.cs deleted file mode 100644 index ccd7287..0000000 --- a/ComfySharp/Types/PrimitiveType.cs +++ /dev/null @@ -1,26 +0,0 @@ -namespace ComfySharp.Types; - -public enum PrimitiveType { - ANY, - CLIP, - CLIP_VISION, - CLIP_VISION_OUTPUT, - CONDITIONING, - CONTROL_NET, - EXTRA_PNGINFO, - FLOAT, - GLIGEN, - IMAGE, - INT, - LATENT, - MASK, - MODEL, - PROMPT, - SAMPLER, - SIGMAS, - STRING, - STYLE_MODEL, - UNIQUE_ID, - UPSCALE_MODEL, - VAE, -} \ No newline at end of file