mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-02 14:36:33 +08:00
优化了脚本生成AST时的代码提示,增加了脚本运行时错误提示。
This commit is contained in:
@@ -69,12 +69,12 @@ namespace Serein.Library.Api
|
||||
/// <param name="argSourceType">决定了方法参数来源</param>
|
||||
/// <param name="argIndex">设置第几个参数</param>
|
||||
void ConnectArgSourceNode(string canvasGuid,
|
||||
string fromNodeGuid,
|
||||
string toNodeGuid,
|
||||
JunctionType fromNodeJunctionType,
|
||||
JunctionType toNodeJunctionType,
|
||||
ConnectionArgSourceType argSourceType,
|
||||
int argIndex);
|
||||
string fromNodeGuid,
|
||||
string toNodeGuid,
|
||||
JunctionType fromNodeJunctionType,
|
||||
JunctionType toNodeJunctionType,
|
||||
ConnectionArgSourceType argSourceType,
|
||||
int argIndex);
|
||||
|
||||
/// <summary>
|
||||
/// 移除两个节点之间的方法调用关系
|
||||
|
||||
@@ -288,11 +288,11 @@ namespace Serein.Library.Api
|
||||
/// <summary>
|
||||
/// 连接类型
|
||||
/// </summary>
|
||||
public ConnectionInvokeType ConnectionInvokeType { get;}
|
||||
public ConnectionInvokeType ConnectionInvokeType { get; } = ConnectionInvokeType.None;
|
||||
/// <summary>
|
||||
/// 表示此次需要在两个节点之间创建连接关系,或是移除连接关系
|
||||
/// </summary>
|
||||
public ConnectChangeType ChangeType { get;}
|
||||
public ConnectChangeType ChangeType { get;}
|
||||
/// <summary>
|
||||
/// 指示需要创建什么类型的连接线
|
||||
/// </summary>
|
||||
@@ -300,7 +300,7 @@ namespace Serein.Library.Api
|
||||
/// <summary>
|
||||
/// 节点对应的方法入参所需参数来源
|
||||
/// </summary>
|
||||
public ConnectionArgSourceType ConnectionArgSourceType { get;}
|
||||
public ConnectionArgSourceType ConnectionArgSourceType { get;}
|
||||
/// <summary>
|
||||
/// 第几个参数
|
||||
/// </summary>
|
||||
|
||||
@@ -105,6 +105,11 @@ namespace Serein.Library
|
||||
/// </summary>
|
||||
public bool HasParamsArg => _paramsArgIndex >= 0;
|
||||
|
||||
/// <summary>
|
||||
/// 是否为静态方法
|
||||
/// </summary>
|
||||
public bool IsStatic { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 新增可变参数
|
||||
/// </summary>
|
||||
@@ -119,10 +124,13 @@ namespace Serein.Library
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var newPd = ParameterDetailss[index].CloneOfModel(this.NodeModel); // 复制出属于本身节点的参数描述
|
||||
newPd.Index = ParameterDetailss.Length; // 更新索引
|
||||
newPd.IsParams = true;
|
||||
ParameterDetailss = ArrayHelper.AddToArray(ParameterDetailss, newPd); // 新增
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -140,6 +148,7 @@ namespace Serein.Library
|
||||
parameterDetails.Index = ParameterDetailss.Length; // 更新索引
|
||||
parameterDetails.IsParams = true;
|
||||
ParameterDetailss = ArrayHelper.AddToArray(ParameterDetailss, parameterDetails); // 新增
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -299,6 +308,7 @@ namespace Serein.Library
|
||||
ParamsArgIndex = this.ParamsArgIndex, // 拷贝
|
||||
ParameterDetailss = this.ParameterDetailss?.Select(p => p?.CloneOfModel(nodeModel)).ToArray(), // 拷贝属于节点方法的新入参描述
|
||||
IsAsync = this.IsAsync, // 拷贝
|
||||
IsStatic = this.IsStatic, // 拷贝
|
||||
};
|
||||
|
||||
return md;
|
||||
|
||||
@@ -13,18 +13,17 @@ namespace Serein.Library
|
||||
/// <summary>
|
||||
/// 基础功能
|
||||
/// </summary>
|
||||
|
||||
[DynamicFlow(Name ="[基础功能]")]
|
||||
public static class SereinBaseFunction
|
||||
{
|
||||
|
||||
|
||||
[NodeAction(NodeType.Action, "对象透传")]
|
||||
public static object SereinTransmissionObject(object value) => value;
|
||||
|
||||
[NodeAction(NodeType.Action, "键值对组装")]
|
||||
public static Dictionary<string, object> SereinKvDataCollectionNode(string argName,
|
||||
public static Dictionary<string, object> SereinKvDataCollection(string argName,
|
||||
params object[] value)
|
||||
{
|
||||
|
||||
var names = argName.Split(';');
|
||||
var count = Math.Min(value.Length, names.Length);
|
||||
var dict = new Dictionary<string, object>();
|
||||
@@ -36,13 +35,13 @@ namespace Serein.Library
|
||||
}
|
||||
|
||||
[NodeAction(NodeType.Action, "数组组装")]
|
||||
public static object[] SereinListDataCollectionNode(params object[] value)
|
||||
public static object[] SereinListDataCollection(params object[] value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
[NodeAction(NodeType.Action, "输出")]
|
||||
public static object[] SereinConsoleNode(params object[] value)
|
||||
public static object[] SereinConsole(params object[] value)
|
||||
{
|
||||
foreach (var item in value)
|
||||
{
|
||||
@@ -104,7 +103,7 @@ namespace Serein.Library
|
||||
}
|
||||
|
||||
|
||||
[NodeAction(NodeType.Action, "设置/更新全局数据")]
|
||||
[NodeAction(NodeType.Action, "设置或更新全局数据")]
|
||||
public static object SereinAddOrUpdateFlowGlobalData(string name, object data)
|
||||
{
|
||||
SereinEnv.AddOrUpdateFlowGlobalData(name, data);
|
||||
|
||||
@@ -16,6 +16,20 @@ namespace Serein.Library.Utils
|
||||
// 类型缓存,键为类型的唯一名称(可以根据实际需求调整生成方式)
|
||||
static Dictionary<string, Type> typeCache = new Dictionary<string, Type>();
|
||||
|
||||
/// <summary>
|
||||
/// 获取运行时创建过的类型
|
||||
/// </summary>
|
||||
/// <param name="className"></param>
|
||||
/// <returns></returns>
|
||||
public static Type GetCacheType(string className)
|
||||
{
|
||||
if(typeCache.TryGetValue(className, out var type))
|
||||
{
|
||||
return type;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static object Resolve(IDictionary<string, object> properties, string typeName)
|
||||
{
|
||||
var obj = CreateObjectWithProperties(properties, typeName);
|
||||
|
||||
@@ -101,8 +101,6 @@ namespace Serein.Library
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置运行流程
|
||||
/// </summary>
|
||||
@@ -138,8 +136,35 @@ namespace Serein.Library
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 尝试在UI线程上触发事件
|
||||
/// </summary>
|
||||
/// <param name="action"></param>
|
||||
/// <returns></returns>
|
||||
public async static Task TriggerEvent(Action action)
|
||||
{
|
||||
if (environment is null)
|
||||
{
|
||||
action?.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
var uco = environment.UIContextOperation;
|
||||
if (uco is null)
|
||||
{
|
||||
action?.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
await uco.InvokeAsync(() =>
|
||||
{
|
||||
action?.Invoke();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user