diff --git a/Library/Api/IFlowContext.cs b/Library/Api/IFlowContext.cs index 0dd624d..db6a3ea 100644 --- a/Library/Api/IFlowContext.cs +++ b/Library/Api/IFlowContext.cs @@ -3,6 +3,7 @@ using Serein.Library.Utils; using System; using System.Collections.Generic; using System.Data.Common; +using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Threading.Tasks; @@ -126,6 +127,24 @@ namespace Serein.Library.Api /// void AddOrUpdate(string nodeModel, object data); + /// + /// 设置共享对象(在同一个上下文中保持一致) + /// + /// + void SetTag(object tag); + + /// + /// 指定泛型尝试获取共享对象(在同一个上下文中保持一致) + /// + /// + T? GetTag(); + + /// + /// 指定泛型尝试获取共享对象(在同一个上下文中保持一致) + /// + /// + /// + bool TryGetTag(out T? tag); /// /// 重置流程状态(用于对象池回收) diff --git a/Library/FlowNode/FlowContext.cs b/Library/FlowNode/FlowContext.cs index 44b6c2e..904c9c0 100644 --- a/Library/FlowNode/FlowContext.cs +++ b/Library/FlowNode/FlowContext.cs @@ -266,7 +266,7 @@ namespace Serein.Library /// 设置共享对象,不建议设置非托管对象 /// /// - private void SetTag(object tag) + public void SetTag(object tag) { lock (_tagLockObj) { @@ -275,10 +275,11 @@ namespace Serein.Library } /// - /// 获取共享对象(将在同一个 Web Socket 调起的上下文中保持一致) + /// 指定泛型获取共享对象(在同一个上下文中保持一致) /// /// - private T? GetTag() + /// + public T? GetTag() { TryGetTag(out T? tag); return tag; @@ -286,11 +287,11 @@ namespace Serein.Library #if NET6_0_OR_GREATER /// - /// 获取共享对象(将在同一个 Web Socket 调起的上下文中保持一致) + /// 指定泛型尝试获取共享对象(在同一个上下文中保持一致) /// /// /// - private bool TryGetTag([NotNullWhen(true)] out T? tag) + public bool TryGetTag([NotNullWhen(true)] out T? tag) { lock (_tagLockObj) { @@ -306,11 +307,11 @@ namespace Serein.Library #else /// - /// 获取共享对象(将在同一个 Web Socket 调起的上下文中保持一致) + /// 指定泛型尝试获取共享对象(在同一个上下文中保持一致) /// /// /// - private bool TryGetTag(out T? tag) + public bool TryGetTag(out T? tag) { lock (_tagLockObj) {