953 lines
50 KiB
C#
953 lines
50 KiB
C#
using System.Globalization;
|
|
using NodePipeline.Abstractions;
|
|
using NodePipeline.Abstractions.Exceptions.NodeFactory;
|
|
using NodePipeline.Abstractions.Interfaces;
|
|
using NodePipeline.Abstractions.Interfaces.Nodes;
|
|
using NodePipeline.Configuration.Abstractions.Models.Execute;
|
|
using NodePipeline.Engine.Abstractions;
|
|
using NodePipeline.Engine.Abstractions.Validation;
|
|
using NodePipeline.Engine.NodeFields;
|
|
using NodePipeline.Engine.Utils;
|
|
|
|
// ReSharper disable CheckNamespace
|
|
// ReSharper disable ConvertTypeCheckPatternToNullCheck
|
|
// ReSharper disable RedundantCast
|
|
// ReSharper disable RedundantNameQualifier
|
|
// ReSharper disable ReturnTypeCanBeNotNullable
|
|
|
|
// ReSharper disable UnusedMember.Local
|
|
// ReSharper disable UnusedParameter.Local
|
|
#nullable enable
|
|
|
|
namespace NodePipeline.Engine.Generated;
|
|
|
|
public sealed class GeneratedNodeFactory : INodeFactory
|
|
{
|
|
public Dictionary<string, Func<INode>> NodeFactories { get; set; } = new();
|
|
public IPipelineLocalizationProvider PipelineLocalizationProvider { get; set; } = new PipelineLocalizationProvider();
|
|
|
|
public INode CreateNode(string pipelineId, NodeConfig config)
|
|
{
|
|
INode? node;
|
|
if (NodeFactories.TryGetValue(config.Type, out var f))
|
|
{
|
|
node = f();
|
|
InitializeNodeFields(pipelineId, node, config.Id);
|
|
return node;
|
|
}
|
|
|
|
switch (config.Type)
|
|
{
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.FileImageSource2"):
|
|
throw new NodeCanNotBeInitializedWithoutFactoryException(pipelineId, config.Type, config.Id);
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.FileImageSource"):
|
|
node = new global::NodePipeline.Application.Nodes.FileImageSourceNode();
|
|
break;
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.GaussianBlur"):
|
|
node = new global::NodePipeline.Application.Nodes.GaussianBlurNode();
|
|
break;
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.MaskApply"):
|
|
node = new global::NodePipeline.Application.Nodes.MaskApplyNode();
|
|
break;
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.SaveImage2"):
|
|
throw new NodeCanNotBeInitializedWithoutFactoryException(pipelineId, config.Type, config.Id);
|
|
case "FileImageDestination":
|
|
node = new global::NodePipeline.Application.Nodes.SaveImageNode();
|
|
break;
|
|
default:
|
|
throw new NodeNotFoundException(pipelineId, config.Type, config.Id);
|
|
}
|
|
InitializeNodeFields(pipelineId, node, config.Id);
|
|
return node ?? throw new NodeWasNotInitializedException(pipelineId, config.Type, config.Id);
|
|
}
|
|
|
|
private void InitializeNodeFields(string pipelineId, INode node, string nodeId)
|
|
{
|
|
switch (node)
|
|
{
|
|
case global::NodePipeline.Application.Nodes.FileImageSource2Node t1:
|
|
Initialize__NodePipeline_Application_Nodes_FileImageSource2Node__NodeFields(t1, nodeId);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.FileImageSourceNode t2:
|
|
Initialize__NodePipeline_Application_Nodes_FileImageSourceNode__NodeFields(t2, nodeId);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.GaussianBlurNode t3:
|
|
Initialize__NodePipeline_Application_Nodes_GaussianBlurNode__NodeFields(t3, nodeId);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.MaskApplyNode t4:
|
|
Initialize__NodePipeline_Application_Nodes_MaskApplyNode__NodeFields(t4, nodeId);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.SaveImage2Node t5:
|
|
Initialize__NodePipeline_Application_Nodes_SaveImage2Node__NodeFields(t5, nodeId);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.SaveImageNode t6:
|
|
Initialize__NodePipeline_Application_Nodes_SaveImageNode__NodeFields(t6, nodeId);
|
|
break;
|
|
default:
|
|
throw new NodeNotFoundException(pipelineId, node.GetType().Name, nodeId);
|
|
}
|
|
}
|
|
|
|
private static void Initialize__NodePipeline_Application_Nodes_FileImageSource2Node__NodeFields(global::NodePipeline.Application.Nodes.FileImageSource2Node node, string nodeId)
|
|
{
|
|
node.Output = new NodePipeline.Abstractions.Models.NodeField<global::NodePipeline.Application.ImageBuffer>()
|
|
{
|
|
Name = "Output",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Output", FieldDirection.Output),
|
|
Direction = FieldDirection.Output,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
}
|
|
|
|
private static void Initialize__NodePipeline_Application_Nodes_FileImageSourceNode__NodeFields(global::NodePipeline.Application.Nodes.FileImageSourceNode node, string nodeId)
|
|
{
|
|
node.FileName = new NodePipeline.Abstractions.Models.NodeField<string>()
|
|
{
|
|
Name = "FileName",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "FileName", FieldDirection.Parameter),
|
|
Direction = FieldDirection.Parameter,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
node.Extension = new NodePipeline.Abstractions.Models.NodeField<string>()
|
|
{
|
|
Name = "Extension",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Extension", FieldDirection.Parameter),
|
|
Direction = FieldDirection.Parameter,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
node.Directory = new NodePipeline.Abstractions.Models.NodeField<string>()
|
|
{
|
|
Name = "Directory",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Directory", FieldDirection.Parameter),
|
|
Direction = FieldDirection.Parameter,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
node.Output = new NodePipeline.Abstractions.Models.NodeField<global::NodePipeline.Application.ImageBuffer?>()
|
|
{
|
|
Name = "Output",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Output", FieldDirection.Output),
|
|
Direction = FieldDirection.Output,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
node.ImageLoaded = new NodePipeline.Abstractions.Models.NodeField<bool>()
|
|
{
|
|
Name = "ImageLoaded",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "ImageLoaded", FieldDirection.Output),
|
|
Direction = FieldDirection.Output,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
}
|
|
|
|
private static void Initialize__NodePipeline_Application_Nodes_GaussianBlurNode__NodeFields(global::NodePipeline.Application.Nodes.GaussianBlurNode node, string nodeId)
|
|
{
|
|
node.Input = new NodePipeline.Abstractions.Models.NodeField<global::NodePipeline.Application.ImageBuffer>()
|
|
{
|
|
Name = "Input",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Input", FieldDirection.Input),
|
|
Direction = FieldDirection.Input,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
node.Radius = new NodePipeline.Abstractions.Models.NodeField<int>()
|
|
{
|
|
Name = "Radius",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Radius", FieldDirection.Parameter),
|
|
Direction = FieldDirection.Parameter,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
node.Output = new NodePipeline.Abstractions.Models.NodeField<global::NodePipeline.Application.ImageBuffer>()
|
|
{
|
|
Name = "Output",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Output", FieldDirection.Output),
|
|
Direction = FieldDirection.Output,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
}
|
|
|
|
private static void Initialize__NodePipeline_Application_Nodes_MaskApplyNode__NodeFields(global::NodePipeline.Application.Nodes.MaskApplyNode node, string nodeId)
|
|
{
|
|
node.InputImage = new NodePipeline.Abstractions.Models.NodeField<global::NodePipeline.Application.ImageBuffer>()
|
|
{
|
|
Name = "InputImage",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "InputImage", FieldDirection.Input),
|
|
Direction = FieldDirection.Input,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
node.Mask = new NodePipeline.Abstractions.Models.NodeField<global::NodePipeline.Application.ImageBuffer>()
|
|
{
|
|
Name = "Mask",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Mask", FieldDirection.Input),
|
|
Direction = FieldDirection.Input,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
node.HasMask = new NodePipeline.Abstractions.Models.NodeField<bool>()
|
|
{
|
|
Name = "HasMask",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "HasMask", FieldDirection.Input),
|
|
Direction = FieldDirection.Input,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
node.Mode = new NodePipeline.Abstractions.Models.NodeField<global::NodePipeline.Application.Nodes.MaskMode>()
|
|
{
|
|
Name = "Mode",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Mode", FieldDirection.Parameter),
|
|
Direction = FieldDirection.Parameter,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
node.OutputImage = new NodePipeline.Abstractions.Models.NodeField<global::NodePipeline.Application.ImageBuffer>()
|
|
{
|
|
Name = "OutputImage",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "OutputImage", FieldDirection.Output),
|
|
Direction = FieldDirection.Output,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
}
|
|
|
|
private static void Initialize__NodePipeline_Application_Nodes_SaveImage2Node__NodeFields(global::NodePipeline.Application.Nodes.SaveImage2Node node, string nodeId)
|
|
{
|
|
node.Input = new NodePipeline.Abstractions.Models.NodeField<global::NodePipeline.Application.ImageBuffer>()
|
|
{
|
|
Name = "Input",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Input", FieldDirection.Input),
|
|
Direction = FieldDirection.Input,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
}
|
|
|
|
private static void Initialize__NodePipeline_Application_Nodes_SaveImageNode__NodeFields(global::NodePipeline.Application.Nodes.SaveImageNode node, string nodeId)
|
|
{
|
|
node.Input = new NodePipeline.Abstractions.Models.NodeField<global::NodePipeline.Application.ImageBuffer>()
|
|
{
|
|
Name = "input",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "input", FieldDirection.Input),
|
|
Direction = FieldDirection.Input,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
node.FileName = new NodePipeline.Abstractions.Models.NodeField<string>()
|
|
{
|
|
Name = "FileName",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "FileName", FieldDirection.Parameter),
|
|
Direction = FieldDirection.Parameter,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
node.Extension = new NodePipeline.Abstractions.Models.NodeField<string>()
|
|
{
|
|
Name = "Extension",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Extension", FieldDirection.Parameter),
|
|
Direction = FieldDirection.Parameter,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
node.Directory = new NodePipeline.Abstractions.Models.NodeField<string>()
|
|
{
|
|
Name = "Directory",
|
|
Code = NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Directory", FieldDirection.Parameter),
|
|
Direction = FieldDirection.Parameter,
|
|
// Description intentionally omitted for runtime
|
|
};
|
|
}
|
|
|
|
|
|
public IEnumerable<string> GetParameterCodes(string nodeType)
|
|
{
|
|
switch (nodeType)
|
|
{
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.FileImageSource2"):
|
|
return GetParameterCodesFor__NodePipeline_Application_Nodes_FileImageSource2Node__Node();
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.FileImageSource"):
|
|
return GetParameterCodesFor__NodePipeline_Application_Nodes_FileImageSourceNode__Node();
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.GaussianBlur"):
|
|
return GetParameterCodesFor__NodePipeline_Application_Nodes_GaussianBlurNode__Node();
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.MaskApply"):
|
|
return GetParameterCodesFor__NodePipeline_Application_Nodes_MaskApplyNode__Node();
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.SaveImage2"):
|
|
return GetParameterCodesFor__NodePipeline_Application_Nodes_SaveImage2Node__Node();
|
|
case "FileImageDestination":
|
|
return GetParameterCodesFor__NodePipeline_Application_Nodes_SaveImageNode__Node();
|
|
default:
|
|
throw new NodeTypeNotFoundException(nodeType);
|
|
}
|
|
}
|
|
|
|
private IEnumerable<string> GetParameterCodesFor__NodePipeline_Application_Nodes_FileImageSource2Node__Node()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
private IEnumerable<string> GetParameterCodesFor__NodePipeline_Application_Nodes_FileImageSourceNode__Node()
|
|
{
|
|
return [
|
|
"FileName",
|
|
"Extension",
|
|
"Directory",
|
|
];
|
|
}
|
|
|
|
private IEnumerable<string> GetParameterCodesFor__NodePipeline_Application_Nodes_GaussianBlurNode__Node()
|
|
{
|
|
return [
|
|
"Radius",
|
|
];
|
|
}
|
|
|
|
private IEnumerable<string> GetParameterCodesFor__NodePipeline_Application_Nodes_MaskApplyNode__Node()
|
|
{
|
|
return [
|
|
"Mode",
|
|
];
|
|
}
|
|
|
|
private IEnumerable<string> GetParameterCodesFor__NodePipeline_Application_Nodes_SaveImage2Node__Node()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
private IEnumerable<string> GetParameterCodesFor__NodePipeline_Application_Nodes_SaveImageNode__Node()
|
|
{
|
|
return [
|
|
"FileName",
|
|
"Extension",
|
|
"Directory",
|
|
];
|
|
}
|
|
|
|
|
|
public object? ReadParameterValue(string pipelineId, string nodeId, string nodeType, string parameterName, string? valueString)
|
|
{
|
|
switch (nodeType)
|
|
{
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.FileImageSource2"):
|
|
return ReadParameterValueFrom__NodePipeline_Application_Nodes_FileImageSource2Node__Node(pipelineId, nodeType, nodeId, parameterName, valueString);
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.FileImageSource"):
|
|
return ReadParameterValueFrom__NodePipeline_Application_Nodes_FileImageSourceNode__Node(pipelineId, nodeType, nodeId, parameterName, valueString);
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.GaussianBlur"):
|
|
return ReadParameterValueFrom__NodePipeline_Application_Nodes_GaussianBlurNode__Node(pipelineId, nodeType, nodeId, parameterName, valueString);
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.MaskApply"):
|
|
return ReadParameterValueFrom__NodePipeline_Application_Nodes_MaskApplyNode__Node(pipelineId, nodeType, nodeId, parameterName, valueString);
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.SaveImage2"):
|
|
return ReadParameterValueFrom__NodePipeline_Application_Nodes_SaveImage2Node__Node(pipelineId, nodeType, nodeId, parameterName, valueString);
|
|
case "FileImageDestination":
|
|
return ReadParameterValueFrom__NodePipeline_Application_Nodes_SaveImageNode__Node(pipelineId, nodeType, nodeId, parameterName, valueString);
|
|
default:
|
|
throw new NodeTypeNotFoundException(nodeType);
|
|
}
|
|
}
|
|
|
|
private static object? ReadParameterValueFrom__NodePipeline_Application_Nodes_FileImageSource2Node__Node(string pipelineId, string nodeType, string nodeId, string parameterName, string? valueString)
|
|
{
|
|
switch (parameterName)
|
|
{
|
|
default:
|
|
throw new NodeParameterNotFoundException(pipelineId, parameterName, nodeType, nodeId);
|
|
}
|
|
}
|
|
|
|
private static object? ReadParameterValueFrom__NodePipeline_Application_Nodes_FileImageSourceNode__Node(string pipelineId, string nodeType, string nodeId, string parameterName, string? valueString)
|
|
{
|
|
switch (parameterName)
|
|
{
|
|
case "FileName":
|
|
return ParseParameter<string>(valueString);
|
|
case "Extension":
|
|
return ParseParameter<string>(valueString);
|
|
case "Directory":
|
|
return ParseParameter<string>(valueString);
|
|
default:
|
|
throw new NodeParameterNotFoundException(pipelineId, parameterName, nodeType, nodeId);
|
|
}
|
|
}
|
|
|
|
private static object? ReadParameterValueFrom__NodePipeline_Application_Nodes_GaussianBlurNode__Node(string pipelineId, string nodeType, string nodeId, string parameterName, string? valueString)
|
|
{
|
|
switch (parameterName)
|
|
{
|
|
case "Radius":
|
|
return ParseParameter<int>(valueString);
|
|
default:
|
|
throw new NodeParameterNotFoundException(pipelineId, parameterName, nodeType, nodeId);
|
|
}
|
|
}
|
|
|
|
private static object? ReadParameterValueFrom__NodePipeline_Application_Nodes_MaskApplyNode__Node(string pipelineId, string nodeType, string nodeId, string parameterName, string? valueString)
|
|
{
|
|
switch (parameterName)
|
|
{
|
|
case "Mode":
|
|
return ParseParameter<global::NodePipeline.Application.Nodes.MaskMode>(valueString);
|
|
default:
|
|
throw new NodeParameterNotFoundException(pipelineId, parameterName, nodeType, nodeId);
|
|
}
|
|
}
|
|
|
|
private static object? ReadParameterValueFrom__NodePipeline_Application_Nodes_SaveImage2Node__Node(string pipelineId, string nodeType, string nodeId, string parameterName, string? valueString)
|
|
{
|
|
switch (parameterName)
|
|
{
|
|
default:
|
|
throw new NodeParameterNotFoundException(pipelineId, parameterName, nodeType, nodeId);
|
|
}
|
|
}
|
|
|
|
private static object? ReadParameterValueFrom__NodePipeline_Application_Nodes_SaveImageNode__Node(string pipelineId, string nodeType, string nodeId, string parameterName, string? valueString)
|
|
{
|
|
switch (parameterName)
|
|
{
|
|
case "FileName":
|
|
return ParseParameter<string>(valueString);
|
|
case "Extension":
|
|
return ParseParameter<string>(valueString);
|
|
case "Directory":
|
|
return ParseParameter<string>(valueString);
|
|
default:
|
|
throw new NodeParameterNotFoundException(pipelineId, parameterName, nodeType, nodeId);
|
|
}
|
|
}
|
|
|
|
|
|
public Dictionary<NodePortKey, NodePortInfo> GetAllPorts(string pipelineId, HashSet<string> nodeTypes, Dictionary<string, IEnumerable<string>> nodeList)
|
|
{
|
|
var result = new Dictionary<NodePortKey, NodePortInfo>();
|
|
foreach (var nodeType in nodeTypes)
|
|
{
|
|
if (!nodeList.TryGetValue(nodeType, out var ids)) continue;
|
|
foreach (var nodeId in ids)
|
|
{
|
|
var ports = GetNodePorts(pipelineId, nodeType, nodeId);
|
|
foreach (var kv in ports) result.Add(kv.Key, kv.Value);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public IEnumerable<NodePortInfo> GetNodeInputPorts(string pipelineId, string nodeType, string nodeId)
|
|
{
|
|
var ports = GetNodePorts(pipelineId, nodeType, nodeId);
|
|
foreach (var kv in ports) if (kv.Key.Input) yield return kv.Value;
|
|
}
|
|
|
|
private Dictionary<NodePortKey, NodePortInfo> GetNodePorts(string pipelineId, string nodeType, string nodeId)
|
|
{
|
|
switch (nodeType)
|
|
{
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.FileImageSource2"): return Get__NodePipeline_Application_Nodes_FileImageSource2Node__NodePorts(nodeId);
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.FileImageSource"): return Get__NodePipeline_Application_Nodes_FileImageSourceNode__NodePorts(nodeId);
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.GaussianBlur"): return Get__NodePipeline_Application_Nodes_GaussianBlurNode__NodePorts(nodeId);
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.MaskApply"): return Get__NodePipeline_Application_Nodes_MaskApplyNode__NodePorts(nodeId);
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.SaveImage2"): return Get__NodePipeline_Application_Nodes_SaveImage2Node__NodePorts(nodeId);
|
|
case "FileImageDestination": return Get__NodePipeline_Application_Nodes_SaveImageNode__NodePorts(nodeId);
|
|
default:
|
|
throw new NodeNotFoundException(pipelineId, nodeType, nodeId);
|
|
}
|
|
}
|
|
|
|
private static Dictionary<NodePortKey, NodePortInfo> Get__NodePipeline_Application_Nodes_FileImageSource2Node__NodePorts(string nodeId)
|
|
{
|
|
return new Dictionary<NodePortKey, NodePortInfo>()
|
|
{
|
|
{
|
|
new NodePortKey(nodeId, "Output", false),
|
|
new NodePortInfo("Output", typeof(global::NodePipeline.Application.ImageBuffer), false, false, false, false)
|
|
},
|
|
};
|
|
}
|
|
|
|
private static Dictionary<NodePortKey, NodePortInfo> Get__NodePipeline_Application_Nodes_FileImageSourceNode__NodePorts(string nodeId)
|
|
{
|
|
return new Dictionary<NodePortKey, NodePortInfo>()
|
|
{
|
|
{
|
|
new NodePortKey(nodeId, "Output", false),
|
|
new NodePortInfo("Output", typeof(global::NodePipeline.Application.ImageBuffer), true, false, false, false)
|
|
},
|
|
{
|
|
new NodePortKey(nodeId, "ImageLoaded", false),
|
|
new NodePortInfo("ImageLoaded", typeof(bool), false, false, false, false)
|
|
},
|
|
};
|
|
}
|
|
|
|
private static Dictionary<NodePortKey, NodePortInfo> Get__NodePipeline_Application_Nodes_GaussianBlurNode__NodePorts(string nodeId)
|
|
{
|
|
return new Dictionary<NodePortKey, NodePortInfo>()
|
|
{
|
|
{
|
|
new NodePortKey(nodeId, "Input", true),
|
|
new NodePortInfo("Input", typeof(global::NodePipeline.Application.ImageBuffer), false, false, false, true)
|
|
},
|
|
{
|
|
new NodePortKey(nodeId, "Output", false),
|
|
new NodePortInfo("Output", typeof(global::NodePipeline.Application.ImageBuffer), false, false, false, false)
|
|
},
|
|
};
|
|
}
|
|
|
|
private static Dictionary<NodePortKey, NodePortInfo> Get__NodePipeline_Application_Nodes_MaskApplyNode__NodePorts(string nodeId)
|
|
{
|
|
return new Dictionary<NodePortKey, NodePortInfo>()
|
|
{
|
|
{
|
|
new NodePortKey(nodeId, "InputImage", true),
|
|
new NodePortInfo("InputImage", typeof(global::NodePipeline.Application.ImageBuffer), false, true, false, true)
|
|
},
|
|
{
|
|
new NodePortKey(nodeId, "Mask", true),
|
|
new NodePortInfo("Mask", typeof(global::NodePipeline.Application.ImageBuffer), false, true, false, true)
|
|
},
|
|
{
|
|
new NodePortKey(nodeId, "HasMask", true),
|
|
new NodePortInfo("HasMask", typeof(bool), false, true, true, true)
|
|
},
|
|
{
|
|
new NodePortKey(nodeId, "OutputImage", false),
|
|
new NodePortInfo("OutputImage", typeof(global::NodePipeline.Application.ImageBuffer), false, false, false, false)
|
|
},
|
|
};
|
|
}
|
|
|
|
private static Dictionary<NodePortKey, NodePortInfo> Get__NodePipeline_Application_Nodes_SaveImage2Node__NodePorts(string nodeId)
|
|
{
|
|
return new Dictionary<NodePortKey, NodePortInfo>()
|
|
{
|
|
{
|
|
new NodePortKey(nodeId, "Input", true),
|
|
new NodePortInfo("Input", typeof(global::NodePipeline.Application.ImageBuffer), false, false, false, true)
|
|
},
|
|
};
|
|
}
|
|
|
|
private static Dictionary<NodePortKey, NodePortInfo> Get__NodePipeline_Application_Nodes_SaveImageNode__NodePorts(string nodeId)
|
|
{
|
|
return new Dictionary<NodePortKey, NodePortInfo>()
|
|
{
|
|
{
|
|
new NodePortKey(nodeId, "input", true),
|
|
new NodePortInfo("input", typeof(global::NodePipeline.Application.ImageBuffer), false, false, false, true)
|
|
},
|
|
};
|
|
}
|
|
|
|
|
|
private IReadOnlyDictionary<string, object> GetNodeOutputs(string pipelineId, string nodeId, INode node)
|
|
{
|
|
switch (node)
|
|
{
|
|
case global::NodePipeline.Application.Nodes.FileImageSource2Node t1:
|
|
return Get__NodePipeline_Application_Nodes_FileImageSource2Node__NodeOutputs(nodeId, t1);
|
|
case global::NodePipeline.Application.Nodes.FileImageSourceNode t2:
|
|
return Get__NodePipeline_Application_Nodes_FileImageSourceNode__NodeOutputs(nodeId, t2);
|
|
case global::NodePipeline.Application.Nodes.GaussianBlurNode t3:
|
|
return Get__NodePipeline_Application_Nodes_GaussianBlurNode__NodeOutputs(nodeId, t3);
|
|
case global::NodePipeline.Application.Nodes.MaskApplyNode t4:
|
|
return Get__NodePipeline_Application_Nodes_MaskApplyNode__NodeOutputs(nodeId, t4);
|
|
case global::NodePipeline.Application.Nodes.SaveImage2Node t5:
|
|
return Get__NodePipeline_Application_Nodes_SaveImage2Node__NodeOutputs(nodeId, t5);
|
|
case global::NodePipeline.Application.Nodes.SaveImageNode t6:
|
|
return Get__NodePipeline_Application_Nodes_SaveImageNode__NodeOutputs(nodeId, t6);
|
|
default:
|
|
throw new NodeNotFoundException(pipelineId, node.GetType().Name, nodeId);
|
|
}
|
|
}
|
|
|
|
|
|
private IReadOnlyDictionary<string, object> Get__NodePipeline_Application_Nodes_FileImageSource2Node__NodeOutputs(string nodeId, global::NodePipeline.Application.Nodes.FileImageSource2Node node)
|
|
{
|
|
return new Dictionary<string, object>
|
|
{
|
|
{ NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Output", FieldDirection.Output), node.Output },
|
|
};
|
|
}
|
|
|
|
private IReadOnlyDictionary<string, object> Get__NodePipeline_Application_Nodes_FileImageSourceNode__NodeOutputs(string nodeId, global::NodePipeline.Application.Nodes.FileImageSourceNode node)
|
|
{
|
|
return new Dictionary<string, object>
|
|
{
|
|
{ NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Output", FieldDirection.Output), node.Output },
|
|
{ NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "ImageLoaded", FieldDirection.Output), node.ImageLoaded },
|
|
};
|
|
}
|
|
|
|
private IReadOnlyDictionary<string, object> Get__NodePipeline_Application_Nodes_GaussianBlurNode__NodeOutputs(string nodeId, global::NodePipeline.Application.Nodes.GaussianBlurNode node)
|
|
{
|
|
return new Dictionary<string, object>
|
|
{
|
|
{ NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "Output", FieldDirection.Output), node.Output },
|
|
};
|
|
}
|
|
|
|
private IReadOnlyDictionary<string, object> Get__NodePipeline_Application_Nodes_MaskApplyNode__NodeOutputs(string nodeId, global::NodePipeline.Application.Nodes.MaskApplyNode node)
|
|
{
|
|
return new Dictionary<string, object>
|
|
{
|
|
{ NodeFieldCodeGenerator.GenerateFieldCode(nodeId, "OutputImage", FieldDirection.Output), node.OutputImage },
|
|
};
|
|
}
|
|
|
|
private IReadOnlyDictionary<string, object> Get__NodePipeline_Application_Nodes_SaveImage2Node__NodeOutputs(string nodeId, global::NodePipeline.Application.Nodes.SaveImage2Node node)
|
|
{
|
|
return new Dictionary<string, object>();
|
|
}
|
|
|
|
private IReadOnlyDictionary<string, object> Get__NodePipeline_Application_Nodes_SaveImageNode__NodeOutputs(string nodeId, global::NodePipeline.Application.Nodes.SaveImageNode node)
|
|
{
|
|
return new Dictionary<string, object>();
|
|
}
|
|
|
|
|
|
public void ConnectPorts<TNode>(string pipelineId, TNode node, string nodeId, Dictionary<string, InputSource> inputs, IReadOnlyDictionary<string, INode> createdNodes) where TNode : INode
|
|
{
|
|
switch (node)
|
|
{
|
|
case global::NodePipeline.Application.Nodes.FileImageSource2Node t1:
|
|
Connect__NodePipeline_Application_Nodes_FileImageSource2Node__NodePorts(pipelineId, t1, nodeId, inputs, createdNodes);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.FileImageSourceNode t2:
|
|
Connect__NodePipeline_Application_Nodes_FileImageSourceNode__NodePorts(pipelineId, t2, nodeId, inputs, createdNodes);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.GaussianBlurNode t3:
|
|
Connect__NodePipeline_Application_Nodes_GaussianBlurNode__NodePorts(pipelineId, t3, nodeId, inputs, createdNodes);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.MaskApplyNode t4:
|
|
Connect__NodePipeline_Application_Nodes_MaskApplyNode__NodePorts(pipelineId, t4, nodeId, inputs, createdNodes);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.SaveImage2Node t5:
|
|
Connect__NodePipeline_Application_Nodes_SaveImage2Node__NodePorts(pipelineId, t5, nodeId, inputs, createdNodes);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.SaveImageNode t6:
|
|
Connect__NodePipeline_Application_Nodes_SaveImageNode__NodePorts(pipelineId, t6, nodeId, inputs, createdNodes);
|
|
break;
|
|
default:
|
|
throw new NodeNotFoundException(pipelineId, node.GetType().Name, nodeId);
|
|
}
|
|
}
|
|
|
|
private PortConnectionInfo? TryConnectPorts<T>(string pipelineId, string nodeId, string nodeType, INodeField<T>? nodeInput, string nodeInputName, Dictionary<string, InputSource> inputs, string inputKey, IReadOnlyDictionary<string, INode> createdNodes, bool isRequired = false) where T : notnull
|
|
{
|
|
if (!inputs.TryGetValue(inputKey, out var connection))
|
|
return !isRequired ? null : throw new InputPortHasNoRequiredConnectionException(pipelineId, inputKey, nodeId, nodeType);
|
|
var fromNodeId = connection.NodeId;
|
|
var fromPortName = connection.OutputName;
|
|
if (nodeInput == null) throw new InputPortNotFoundException(pipelineId, inputKey, nodeId, nodeType);
|
|
if (!createdNodes.TryGetValue(fromNodeId, out var fromNode)) throw new OutputPortNodeNotFoundException(pipelineId, fromNodeId, nodeId);
|
|
var outputs = GetNodeOutputs(pipelineId, fromNodeId, fromNode);
|
|
var outputFieldKey = NodeFieldCodeGenerator.GenerateFieldCode(fromNodeId, fromPortName, FieldDirection.Output);
|
|
if (!outputs.TryGetValue(outputFieldKey, out var outputFieldObj)) throw new OutputPortNotFoundException(pipelineId, fromPortName, fromNodeId, nodeId);
|
|
var fromNodeType = GetNodeType(pipelineId, fromNodeId, fromNode);
|
|
if (outputFieldObj is INodeField<T> outStrict && nodeInput is INodeField<T> inStrict)
|
|
{
|
|
PortConnector.ConnectStatic(outStrict, inStrict);
|
|
return new PortConnectionInfo(true, outputFieldObj, fromPortName, fromNodeType, fromNodeId);
|
|
}
|
|
return new PortConnectionInfo(false, outputFieldObj, fromPortName, fromNodeType, fromNodeId);
|
|
}
|
|
|
|
private void Connect__NodePipeline_Application_Nodes_FileImageSource2Node__NodePorts(string pipelineId, global::NodePipeline.Application.Nodes.FileImageSource2Node node, string nodeId, Dictionary<string, InputSource> inputs, IReadOnlyDictionary<string, INode> createdNodes)
|
|
{
|
|
}
|
|
|
|
private void Connect__NodePipeline_Application_Nodes_FileImageSourceNode__NodePorts(string pipelineId, global::NodePipeline.Application.Nodes.FileImageSourceNode node, string nodeId, Dictionary<string, InputSource> inputs, IReadOnlyDictionary<string, INode> createdNodes)
|
|
{
|
|
}
|
|
|
|
private void Connect__NodePipeline_Application_Nodes_GaussianBlurNode__NodePorts(string pipelineId, global::NodePipeline.Application.Nodes.GaussianBlurNode node, string nodeId, Dictionary<string, InputSource> inputs, IReadOnlyDictionary<string, INode> createdNodes)
|
|
{
|
|
ConnectPortsStruct(pipelineId, nodeId, "NodePipeline.Application.Nodes.GaussianBlurNode", node.Input, nameof(node.Input), inputs, "Input", createdNodes, disallowNullableOutput: false, isRequired: true);
|
|
}
|
|
|
|
private void Connect__NodePipeline_Application_Nodes_MaskApplyNode__NodePorts(string pipelineId, global::NodePipeline.Application.Nodes.MaskApplyNode node, string nodeId, Dictionary<string, InputSource> inputs, IReadOnlyDictionary<string, INode> createdNodes)
|
|
{
|
|
ConnectPortsStruct(pipelineId, nodeId, "NodePipeline.Application.Nodes.MaskApplyNode", node.InputImage, nameof(node.InputImage), inputs, "InputImage", createdNodes, disallowNullableOutput: false, isRequired: true);
|
|
ConnectPortsStruct(pipelineId, nodeId, "NodePipeline.Application.Nodes.MaskApplyNode", node.Mask, nameof(node.Mask), inputs, "Mask", createdNodes, disallowNullableOutput: false, isRequired: true);
|
|
ConnectPortsStruct(pipelineId, nodeId, "NodePipeline.Application.Nodes.MaskApplyNode", node.HasMask, nameof(node.HasMask), inputs, "HasMask", createdNodes, disallowNullableOutput: true, isRequired: true);
|
|
}
|
|
|
|
private void Connect__NodePipeline_Application_Nodes_SaveImage2Node__NodePorts(string pipelineId, global::NodePipeline.Application.Nodes.SaveImage2Node node, string nodeId, Dictionary<string, InputSource> inputs, IReadOnlyDictionary<string, INode> createdNodes)
|
|
{
|
|
ConnectPortsStruct(pipelineId, nodeId, "NodePipeline.Application.Nodes.SaveImage2Node", node.Input, nameof(node.Input), inputs, "Input", createdNodes, disallowNullableOutput: false, isRequired: true);
|
|
}
|
|
|
|
private void Connect__NodePipeline_Application_Nodes_SaveImageNode__NodePorts(string pipelineId, global::NodePipeline.Application.Nodes.SaveImageNode node, string nodeId, Dictionary<string, InputSource> inputs, IReadOnlyDictionary<string, INode> createdNodes)
|
|
{
|
|
ConnectPortsStruct(pipelineId, nodeId, "NodePipeline.Application.Nodes.SaveImageNode", node.Input, nameof(node.Input), inputs, "input", createdNodes, disallowNullableOutput: false, isRequired: true);
|
|
}
|
|
|
|
|
|
private void ConnectPortsStruct<T>(string pipelineId, string nodeId,string nodeType, INodeField<T>? nodeInput, string nodeInputName, Dictionary<string, InputSource> inputs,
|
|
string inputKey, IReadOnlyDictionary<string, INode> createdNodes, bool disallowNullableOutput = false, bool isRequired = false)
|
|
where T : struct
|
|
{
|
|
var portConnectionInfo = TryConnectPorts(pipelineId, nodeId, nodeType, nodeInput, nodeInputName, inputs, inputKey, createdNodes, isRequired);
|
|
if (portConnectionInfo is null || portConnectionInfo.Connected) return;
|
|
if (typeof(T).IsValueType && portConnectionInfo.OutputFieldObj is INodeField<T?> outputField)
|
|
{
|
|
PortConnector.ConnectRuntimeFromNullableStruct(outputField, nodeInput!,
|
|
nodeId, inputKey, portConnectionInfo.FromNodeId, portConnectionInfo.FromPortName);
|
|
return;
|
|
}
|
|
if (portConnectionInfo.OutputFieldObj is INodeField<T?> outNullable && nodeInput is INodeField<T?> inNullable)
|
|
{
|
|
PortConnector.ConnectRuntimeBothNullable(outNullable, inNullable);
|
|
return;
|
|
}
|
|
if (portConnectionInfo.OutputFieldObj is INodeField<T?> outNToStrict && nodeInput != null)
|
|
{
|
|
if (disallowNullableOutput)
|
|
{
|
|
throw new NonNullableInputRestrictsConnectionToNullableOutputException(pipelineId, nodeId, nodeType, inputKey, portConnectionInfo.FromPortName, portConnectionInfo.FromNodeId);
|
|
}
|
|
PortConnector.ConnectRuntimeFromNullableStruct(outNToStrict, nodeInput, currentNodeId: nodeId,
|
|
inputPortName: inputKey, sourceNodeId: portConnectionInfo.FromNodeId, outputPortName: portConnectionInfo.FromPortName);
|
|
return;
|
|
}
|
|
if (portConnectionInfo.OutputFieldObj is INodeField<T> outStrictToN && nodeInput is INodeField<T?> inNullable2)
|
|
{
|
|
PortConnector.ConnectRuntimeToNullableStruct(outStrictToN, inNullable2);
|
|
return;
|
|
}
|
|
throw new PortsTypeMismatchException(pipelineId, inputKey, nodeType, nodeId,
|
|
portConnectionInfo.FromPortName, portConnectionInfo.FromNodeType, portConnectionInfo.FromNodeId);
|
|
}
|
|
|
|
private void ConnectPortsClass<T>(string pipelineId, string nodeId,string nodeType, INodeField<T>? nodeInput, string nodeInputName, Dictionary<string, InputSource> inputs,
|
|
string inputKey, IReadOnlyDictionary<string, INode> createdNodes, bool disallowNullableOutput = false, bool isRequired = false)
|
|
where T : class
|
|
{
|
|
var portConnectionInfo = TryConnectPorts(pipelineId, nodeId, nodeType, nodeInput, nodeInputName, inputs, inputKey, createdNodes, isRequired);
|
|
if (portConnectionInfo is null || portConnectionInfo.Connected) return;
|
|
if (!typeof(T).IsValueType && portConnectionInfo.OutputFieldObj is INodeField<T?> outputField)
|
|
{
|
|
PortConnector.ConnectRuntimeFromNullableClass(outputField, nodeInput!,
|
|
nodeId, inputKey, portConnectionInfo.FromNodeId, portConnectionInfo.FromPortName);
|
|
return;
|
|
}
|
|
if (portConnectionInfo.OutputFieldObj is INodeField<T?> outNullable && nodeInput is INodeField<T?> inNullable)
|
|
{
|
|
PortConnector.ConnectRuntimeBothNullable(outNullable, (INodeField<T?>)inNullable);
|
|
return;
|
|
}
|
|
if (portConnectionInfo.OutputFieldObj is INodeField<T?> outNToStrict && nodeInput != null)
|
|
{
|
|
if (disallowNullableOutput)
|
|
{
|
|
throw new NonNullableInputRestrictsConnectionToNullableOutputException(pipelineId, nodeId, nodeType, inputKey, portConnectionInfo.FromPortName, portConnectionInfo.FromNodeId);
|
|
}
|
|
PortConnector.ConnectRuntimeFromNullableClass(outNToStrict, nodeInput, currentNodeId: nodeId,
|
|
inputPortName: inputKey, sourceNodeId: portConnectionInfo.FromNodeId, outputPortName: portConnectionInfo.FromPortName);
|
|
return;
|
|
}
|
|
if (portConnectionInfo.OutputFieldObj is INodeField<T> outStrictToN && nodeInput is INodeField<T?> inNullable2)
|
|
{
|
|
PortConnector.ConnectRuntimeToNullableClass(outStrictToN, (INodeField<T?>)inNullable2);
|
|
return;
|
|
}
|
|
throw new PortsTypeMismatchException(pipelineId, inputKey, nodeType, nodeId,
|
|
portConnectionInfo.FromPortName, portConnectionInfo.FromNodeType, portConnectionInfo.FromNodeId);
|
|
}
|
|
|
|
private static T? ParseParameter<T>(string? valueString)
|
|
{
|
|
var type = typeof(T);
|
|
if (type == typeof(string)) return valueString is not null ? (T)(object)valueString : default;
|
|
if (string.IsNullOrEmpty(valueString)) return default;
|
|
if (type == typeof(int)) return (T)(object)int.Parse(valueString);
|
|
if (type == typeof(double)) return (T)(object)double.Parse(valueString, CultureInfo.InvariantCulture);
|
|
if (type == typeof(bool)) return (T)(object)bool.Parse(valueString);
|
|
if (type == typeof(global::NodePipeline.Application.Nodes.MaskMode)) return (T)(object)Enum.Parse<global::NodePipeline.Application.Nodes.MaskMode>(valueString);
|
|
throw new NotSupportedException(type.Name);
|
|
}
|
|
|
|
public object? GetParameterDefaultValue(string nodeType, string parameterName)
|
|
{
|
|
switch (nodeType)
|
|
{
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.FileImageSource2"):
|
|
return GetParameterDefaultValueFor__NodePipeline_Application_Nodes_FileImageSource2Node__Node(parameterName);
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.FileImageSource"):
|
|
return GetParameterDefaultValueFor__NodePipeline_Application_Nodes_FileImageSourceNode__Node(parameterName);
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.GaussianBlur"):
|
|
return GetParameterDefaultValueFor__NodePipeline_Application_Nodes_GaussianBlurNode__Node(parameterName);
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.MaskApply"):
|
|
return GetParameterDefaultValueFor__NodePipeline_Application_Nodes_MaskApplyNode__Node(parameterName);
|
|
case var t when t == NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.SaveImage2"):
|
|
return GetParameterDefaultValueFor__NodePipeline_Application_Nodes_SaveImage2Node__Node(parameterName);
|
|
case "FileImageDestination":
|
|
return GetParameterDefaultValueFor__NodePipeline_Application_Nodes_SaveImageNode__Node(parameterName);
|
|
default:
|
|
throw new NodeParameterNotFoundException(parameterName, nodeType);
|
|
}
|
|
}
|
|
|
|
private static object GetParameterDefaultValueFor__NodePipeline_Application_Nodes_FileImageSource2Node__Node(string parameterName)
|
|
{
|
|
switch (parameterName)
|
|
{
|
|
default:
|
|
throw new NodeParameterNotFoundException(parameterName, "NodePipeline.Application.Nodes.FileImageSource2");
|
|
}
|
|
}
|
|
|
|
private static object GetParameterDefaultValueFor__NodePipeline_Application_Nodes_FileImageSourceNode__Node(string parameterName)
|
|
{
|
|
switch (parameterName)
|
|
{
|
|
case "FileName":
|
|
return GetDefaultValue<string>();
|
|
case "Extension":
|
|
return GetDefaultValue<string>();
|
|
case "Directory":
|
|
return GetDefaultValue<string>();
|
|
default:
|
|
throw new NodeParameterNotFoundException(parameterName, "NodePipeline.Application.Nodes.FileImageSource");
|
|
}
|
|
}
|
|
|
|
private static object GetParameterDefaultValueFor__NodePipeline_Application_Nodes_GaussianBlurNode__Node(string parameterName)
|
|
{
|
|
switch (parameterName)
|
|
{
|
|
case "Radius":
|
|
return GetDefaultValue<int>();
|
|
default:
|
|
throw new NodeParameterNotFoundException(parameterName, "NodePipeline.Application.Nodes.GaussianBlur");
|
|
}
|
|
}
|
|
|
|
private static object GetParameterDefaultValueFor__NodePipeline_Application_Nodes_MaskApplyNode__Node(string parameterName)
|
|
{
|
|
switch (parameterName)
|
|
{
|
|
case "Mode":
|
|
return GetDefaultValue<global::NodePipeline.Application.Nodes.MaskMode>();
|
|
default:
|
|
throw new NodeParameterNotFoundException(parameterName, "NodePipeline.Application.Nodes.MaskApply");
|
|
}
|
|
}
|
|
|
|
private static object GetParameterDefaultValueFor__NodePipeline_Application_Nodes_SaveImage2Node__Node(string parameterName)
|
|
{
|
|
switch (parameterName)
|
|
{
|
|
default:
|
|
throw new NodeParameterNotFoundException(parameterName, "NodePipeline.Application.Nodes.SaveImage2");
|
|
}
|
|
}
|
|
|
|
private static object GetParameterDefaultValueFor__NodePipeline_Application_Nodes_SaveImageNode__Node(string parameterName)
|
|
{
|
|
switch (parameterName)
|
|
{
|
|
case "FileName":
|
|
return GetDefaultValue<string>();
|
|
case "Extension":
|
|
return ".jpg";
|
|
case "Directory":
|
|
return GetDefaultValue<string>();
|
|
default:
|
|
throw new NodeParameterNotFoundException(parameterName, "FileImageDestination");
|
|
}
|
|
}
|
|
|
|
private static T? GetDefaultValue<T>()
|
|
{
|
|
var type = typeof(T);
|
|
if (type == typeof(string)) return (T)(object)string.Empty;
|
|
if (type == typeof(int)) return (T)(object)0;
|
|
if (type == typeof(double)) return (T)(object)0d;
|
|
if (type == typeof(decimal)) return (T)(object)0m;
|
|
if (type == typeof(bool)) return (T)(object)false;
|
|
if (type == typeof(Guid)) return (T)(object)Guid.Empty;
|
|
if (type.IsEnum) return default;
|
|
throw new NotSupportedException(type.Name);
|
|
}
|
|
|
|
public void SetNodeParametersValues<TNode>(string pipelineId, TNode node, string nodeId, Dictionary<string, object?> parameters) where TNode : INode
|
|
{
|
|
switch (node)
|
|
{
|
|
case global::NodePipeline.Application.Nodes.FileImageSource2Node t1:
|
|
Set__NodePipeline_Application_Nodes_FileImageSource2Node__NodeParametersValues(t1, nodeId, parameters);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.FileImageSourceNode t2:
|
|
Set__NodePipeline_Application_Nodes_FileImageSourceNode__NodeParametersValues(t2, nodeId, parameters);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.GaussianBlurNode t3:
|
|
Set__NodePipeline_Application_Nodes_GaussianBlurNode__NodeParametersValues(t3, nodeId, parameters);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.MaskApplyNode t4:
|
|
Set__NodePipeline_Application_Nodes_MaskApplyNode__NodeParametersValues(t4, nodeId, parameters);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.SaveImage2Node t5:
|
|
Set__NodePipeline_Application_Nodes_SaveImage2Node__NodeParametersValues(t5, nodeId, parameters);
|
|
break;
|
|
case global::NodePipeline.Application.Nodes.SaveImageNode t6:
|
|
Set__NodePipeline_Application_Nodes_SaveImageNode__NodeParametersValues(t6, nodeId, parameters);
|
|
break;
|
|
default:
|
|
throw new NodeNotFoundException(pipelineId, node.GetType().Name, nodeId);
|
|
}
|
|
}
|
|
|
|
private static void Set__NodePipeline_Application_Nodes_FileImageSource2Node__NodeParametersValues(global::NodePipeline.Application.Nodes.FileImageSource2Node node, string nodeId, Dictionary<string, object?> parameters)
|
|
{
|
|
}
|
|
|
|
private static void Set__NodePipeline_Application_Nodes_FileImageSourceNode__NodeParametersValues(global::NodePipeline.Application.Nodes.FileImageSourceNode node, string nodeId, Dictionary<string, object?> parameters)
|
|
{
|
|
if (parameters.TryGetValue("FileName", out var val1) && val1 is string typedVal1)
|
|
node.FileName.Value = typedVal1;
|
|
if (parameters.TryGetValue("Extension", out var val2) && val2 is string typedVal2)
|
|
node.Extension.Value = typedVal2;
|
|
if (parameters.TryGetValue("Directory", out var val3) && val3 is string typedVal3)
|
|
node.Directory.Value = typedVal3;
|
|
}
|
|
|
|
private static void Set__NodePipeline_Application_Nodes_GaussianBlurNode__NodeParametersValues(global::NodePipeline.Application.Nodes.GaussianBlurNode node, string nodeId, Dictionary<string, object?> parameters)
|
|
{
|
|
if (parameters.TryGetValue("Radius", out var val1) && val1 is int typedVal1)
|
|
node.Radius.Value = typedVal1;
|
|
}
|
|
|
|
private static void Set__NodePipeline_Application_Nodes_MaskApplyNode__NodeParametersValues(global::NodePipeline.Application.Nodes.MaskApplyNode node, string nodeId, Dictionary<string, object?> parameters)
|
|
{
|
|
if (parameters.TryGetValue("Mode", out var val1) && val1 is global::NodePipeline.Application.Nodes.MaskMode typedVal1)
|
|
node.Mode.Value = typedVal1;
|
|
}
|
|
|
|
private static void Set__NodePipeline_Application_Nodes_SaveImage2Node__NodeParametersValues(global::NodePipeline.Application.Nodes.SaveImage2Node node, string nodeId, Dictionary<string, object?> parameters)
|
|
{
|
|
}
|
|
|
|
private static void Set__NodePipeline_Application_Nodes_SaveImageNode__NodeParametersValues(global::NodePipeline.Application.Nodes.SaveImageNode node, string nodeId, Dictionary<string, object?> parameters)
|
|
{
|
|
if (parameters.TryGetValue("FileName", out var val1) && val1 is string typedVal1)
|
|
node.FileName.Value = typedVal1;
|
|
if (parameters.TryGetValue("Extension", out var val2) && val2 is string typedVal2)
|
|
node.Extension.Value = typedVal2;
|
|
if (parameters.TryGetValue("Directory", out var val3) && val3 is string typedVal3)
|
|
node.Directory.Value = typedVal3;
|
|
}
|
|
|
|
|
|
private static string GetNodeType(string pipelineId, string nodeId, INode node)
|
|
{
|
|
switch (node)
|
|
{
|
|
case global::NodePipeline.Application.Nodes.FileImageSource2Node:
|
|
return NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.FileImageSource2");
|
|
case global::NodePipeline.Application.Nodes.FileImageSourceNode:
|
|
return NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.FileImageSource");
|
|
case global::NodePipeline.Application.Nodes.GaussianBlurNode:
|
|
return NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.GaussianBlur");
|
|
case global::NodePipeline.Application.Nodes.MaskApplyNode:
|
|
return NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.MaskApply");
|
|
case global::NodePipeline.Application.Nodes.SaveImage2Node:
|
|
return NodeNamePrefixSettings.TrimNodeName("NodePipeline.Application.Nodes.SaveImage2");
|
|
case global::NodePipeline.Application.Nodes.SaveImageNode:
|
|
return "FileImageDestination";
|
|
default:
|
|
throw new NodeNotFoundException(pipelineId, node.GetType().Name, nodeId);
|
|
}
|
|
}
|
|
|
|
|
|
private record PortConnectionInfo(bool Connected, object? OutputFieldObj, string FromPortName, string FromNodeType, string FromNodeId);
|
|
}
|
|
#nullable restore
|