mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-07 16:36:35 +08:00
1. 重新设计了Generate项目及相关特性的命名,避免与其他类型混淆。
2. 补充了部分注释。 3. 修改了删除容器节点时,容器内子节点未正确删除的问题。
This commit is contained in:
91
NodeFlow/Model/Operations/ChangeParameterOperation.cs
Normal file
91
NodeFlow/Model/Operations/ChangeParameterOperation.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using Microsoft.CodeAnalysis;
|
||||
using Serein.Library.Api;
|
||||
using Serein.NodeFlow.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.NodeFlow.Model.Operations
|
||||
{
|
||||
internal class ChangeParameterOperation : OperationBase
|
||||
{
|
||||
public override string Theme => nameof(ChangeParameterOperation);
|
||||
|
||||
public string NodeGuid { get; set; }
|
||||
public bool IsAdd{ get; set; }
|
||||
|
||||
public int ParamIndex { get; set; }
|
||||
|
||||
|
||||
private IFlowNode nodeModel;
|
||||
|
||||
|
||||
public override bool ValidationParameter()
|
||||
{
|
||||
if (!flowModelService.TryGetNodeModel(NodeGuid, out var nodeModel))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.nodeModel = nodeModel;
|
||||
|
||||
var pds = nodeModel.MethodDetails.ParameterDetailss;
|
||||
var parameterCount = pds.Length;
|
||||
if (ParamIndex >= parameterCount)
|
||||
{
|
||||
return false; // 需要被添加的下标索引大于入参数组的长度
|
||||
}
|
||||
if (IsAdd)
|
||||
{
|
||||
if (pds[ParamIndex].IsParams == false)
|
||||
{
|
||||
return false; // 对应的入参并非可选参数中的一部分
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override Task<bool> ExecuteAsync()
|
||||
{
|
||||
|
||||
if (!ValidationParameter()) return Task.FromResult(false);
|
||||
|
||||
if (IsAdd)
|
||||
{
|
||||
if (nodeModel.MethodDetails.AddParamsArg(ParamIndex))
|
||||
{
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nodeModel.MethodDetails.RemoveParamsArg(ParamIndex))
|
||||
{
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ToInfo()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user