From 0dcb0ff947d85cccc5c990daf4b6ee5a237b20b9 Mon Sep 17 00:00:00 2001
From: fengjiayi <12821976+ning_xi@user.noreply.gitee.com>
Date: Mon, 25 Aug 2025 11:16:15 +0800
Subject: [PATCH] =?UTF-8?q?1.=20=E5=AE=9E=E7=8E=B0=E4=BA=86Tag=E7=9A=84Get?=
=?UTF-8?q?/Set=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Library/Api/IFlowContext.cs | 19 +++++++++++++++++++
Library/FlowNode/FlowContext.cs | 15 ++++++++-------
2 files changed, 27 insertions(+), 7 deletions(-)
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)
{