重写了触发器底层逻辑

This commit is contained in:
fengjiayi
2024-10-11 16:46:16 +08:00
parent 2d0f354895
commit aa85c907a3
27 changed files with 770 additions and 392 deletions

View File

@@ -38,6 +38,11 @@ namespace Serein.Library.Core.NodeFlow
{
// 获取 Task<> 的泛型参数类型
var innerType = type.GetGenericArguments()[0];
if (innerType.IsGenericType && type.GetGenericTypeDefinition() == typeof(IFlipflopContext<>))
{
var flipflop = type.GetGenericArguments()[0];
return true;
}
// 判断 innerType 是否继承 IFlipflopContext
//if (typeof(IFlipflopContext).IsAssignableFrom(innerType))
@@ -50,11 +55,11 @@ namespace Serein.Library.Core.NodeFlow
//}
// 检查泛型参数是否为 Flipflop<>
if (innerType == typeof(IFlipflopContext))
//if (innerType == typeof(IFlipflopContext))
//if (innerType.IsGenericType && innerType.GetGenericTypeDefinition() == typeof(FlipflopContext<>))
{
return true;
}
//{
//return true;
//}
}
return false;
@@ -64,20 +69,21 @@ namespace Serein.Library.Core.NodeFlow
/// <summary>
/// 触发器上下文
/// </summary>
public class FlipflopContext : IFlipflopContext
public class FlipflopContext<TResult> : IFlipflopContext<TResult>
{
public FlipflopStateType State { get; set; }
public TriggerData TriggerData { get; set; }
public TriggerType Type { get; set; }
public TResult Value { get; set; }
public FlipflopContext(FlipflopStateType ffState)
{
State = ffState;
}
public FlipflopContext(FlipflopStateType ffState, TriggerData data)
public FlipflopContext(FlipflopStateType ffState, TResult value)
{
State = ffState;
TriggerData = data;
Value = value;
}