mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-09 09:26:35 +08:00
添加了@Dtc(数据类型转换)、@Data(获取全局数据)表达式
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user