添加了@Dtc(数据类型转换)、@Data(获取全局数据)表达式

This commit is contained in:
fengjiayi
2024-12-09 22:57:06 +08:00
parent 8c54b9a014
commit 0f46b7ef63
27 changed files with 628 additions and 97 deletions

View File

@@ -1,5 +1,6 @@
using Serein.Library.Api;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
@@ -11,6 +12,39 @@ namespace Serein.Library.Utils
public static class SereinEnv
{
private static IFlowEnvironment environment;
/// <summary>
/// 记录全局数据
/// </summary>
public static ConcurrentDictionary<string, object> EnvGlobalData { get; } = new ConcurrentDictionary<string, object>();
/// <summary>
/// 清空全局数据
/// </summary>
public static void ClearGlobalData()
{
foreach (var nodeObj in EnvGlobalData.Values)
{
if (nodeObj != null)
{
if (typeof(IDisposable).IsAssignableFrom(nodeObj?.GetType()) && nodeObj is IDisposable disposable)
{
disposable?.Dispose();
}
}
else
{
}
}
EnvGlobalData.Clear();
}
/// <summary>
/// 设置运行流程
/// </summary>
/// <param name="environment"></param>
public static void SetEnv(IFlowEnvironment environment)
{
if (environment != null)
@@ -18,10 +52,22 @@ namespace Serein.Library.Utils
SereinEnv.environment = environment;
}
}
public static void WriteLine(InfoType type, string message, InfoClass @class = InfoClass.Trivial)
/// <summary>
/// 输出内容
/// </summary>
/// <param name="type">类型</param>
/// <param name="message">内容</param>
/// <param name="class">级别</param>
public static void WriteLine(InfoType type, string message, InfoClass @class = InfoClass.General)
{
SereinEnv.environment.WriteLine(type,message,@class);
}
}
}