mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-20 00:06:45 +08:00
暂停更新 Workbench(WPF)项目
This commit is contained in:
@@ -82,9 +82,6 @@ namespace Serein.Library.Api
|
||||
/// </summary>
|
||||
void Exit();
|
||||
|
||||
|
||||
|
||||
|
||||
/*/// <summary>
|
||||
/// 定时循环触发
|
||||
/// </summary>
|
||||
|
||||
@@ -296,19 +296,6 @@ namespace Serein.Library.Api
|
||||
this.Position = position;
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 区域子项节点添加事件参数
|
||||
///// </summary>
|
||||
///// <param name="nodeModel">节点对象</param>
|
||||
///// <param name="isAddInRegion">是否添加在区域中</param>
|
||||
///// <param name="regeionGuid">区域Guid</param>
|
||||
//public NodeCreateEventArgs(object nodeModel, bool isAddInRegion, string regeionGuid)
|
||||
//{
|
||||
// this.NodeModel = nodeModel;
|
||||
// this.RegeionGuid = regeionGuid;
|
||||
// this.IsAddInRegion = isAddInRegion;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 节点Model对象
|
||||
/// </summary>
|
||||
@@ -565,69 +552,11 @@ namespace Serein.Library.Api
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 运行环境
|
||||
/// 流程环境事件接口
|
||||
/// </summary>
|
||||
public interface IFlowEnvironment
|
||||
public interface IFlowEnvironmentEvent
|
||||
{
|
||||
#region 属性
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>单例模式IOC容器,内部维护了一个实例字典,默认使用类型的FullName作为Key,如果以“接口-实现类”的方式注册,那么将使用接口类型的FullName作为Key。</para>
|
||||
/// <para>当某个类型注册绑定成功后,将不会因为其它地方尝试注册相同类型的行为导致类型被重新创建。</para>
|
||||
/// </summary>
|
||||
ISereinIOC IOC { get; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 环境名称
|
||||
/// </summary>
|
||||
string EnvName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否全局中断
|
||||
/// </summary>
|
||||
bool IsGlobalInterrupt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>表示是否正在控制远程</para>
|
||||
/// <para>Local control remote env</para>
|
||||
/// </summary>
|
||||
bool IsControlRemoteEnv { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 信息输出等级
|
||||
/// </summary>
|
||||
InfoClass InfoClass { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程运行状态
|
||||
/// </summary>
|
||||
RunState FlowState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 全局触发器运行状态
|
||||
/// </summary>
|
||||
RunState FlipFlopState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 表示当前环境
|
||||
/// </summary>
|
||||
IFlowEnvironment CurrentEnv { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 由运行环境提供的UI线程上下文操作,用于类库中需要在UI线程中操作视觉元素的场景
|
||||
/// </summary>
|
||||
UIContextOperation UIContextOperation { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region 事件
|
||||
|
||||
/// <summary>
|
||||
/// 加载Dll
|
||||
/// </summary>
|
||||
@@ -712,6 +641,64 @@ namespace Serein.Library.Api
|
||||
/// 运行环境输出
|
||||
/// </summary>
|
||||
event EnvOutHandler OnEnvOut;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 运行环境
|
||||
/// </summary>
|
||||
public interface IFlowEnvironment
|
||||
{
|
||||
#region 属性
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// <para>单例模式IOC容器,内部维护了一个实例字典,默认使用类型的FullName作为Key,如果以“接口-实现类”的方式注册,那么将使用接口类型的FullName作为Key。</para>
|
||||
/// <para>当某个类型注册绑定成功后,将不会因为其它地方尝试注册相同类型的行为导致类型被重新创建。</para>
|
||||
/// </summary>
|
||||
ISereinIOC IOC { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 环境名称
|
||||
/// </summary>
|
||||
string EnvName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否全局中断
|
||||
/// </summary>
|
||||
bool IsGlobalInterrupt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// <para>表示是否正在控制远程</para>
|
||||
/// <para>Local control remote env</para>
|
||||
/// </summary>
|
||||
bool IsControlRemoteEnv { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 信息输出等级
|
||||
/// </summary>
|
||||
InfoClass InfoClass { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程运行状态
|
||||
/// </summary>
|
||||
RunState FlowState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 全局触发器运行状态
|
||||
/// </summary>
|
||||
RunState FlipFlopState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 表示当前环境
|
||||
/// </summary>
|
||||
IFlowEnvironment CurrentEnv { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 由运行环境提供的UI线程上下文操作,用于类库中需要在UI线程中操作视觉元素的场景
|
||||
/// </summary>
|
||||
UIContextOperation UIContextOperation { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region 基本接口
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Serein.Library
|
||||
/// <summary>
|
||||
/// 方法描述信息
|
||||
/// </summary>
|
||||
public class MethodDetailsInfo
|
||||
public class MethodDetailsInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 属于哪个程序集
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
@@ -14,7 +15,43 @@ namespace Serein.Library.Utils
|
||||
public static class ConvertHelper
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 对象转JSON文本
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public static string ToJsonText(this object obj)
|
||||
{
|
||||
var jsonText = JsonConvert.SerializeObject(obj, Formatting.Indented);
|
||||
return jsonText;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// JSON文本转对象
|
||||
/// </summary>
|
||||
/// <typeparam name="T">转换类型</typeparam>
|
||||
/// <param name="json">JSON文本</param>
|
||||
/// <returns></returns>
|
||||
public static T ToJsonObject<T>(this string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(json);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 对象转换(好像没啥用)
|
||||
/// </summary>
|
||||
/// <typeparam name="TResult"></typeparam>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static TResult ToConvert<TResult>(this object data)
|
||||
{
|
||||
var type = typeof(TResult);
|
||||
@@ -25,6 +62,14 @@ namespace Serein.Library.Utils
|
||||
return (TResult)data.ToConvert(type);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 对象转换(好像没啥用)
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
public static object ToConvert(this object data, Type type)
|
||||
{
|
||||
if (type.IsValueType)
|
||||
@@ -44,12 +89,24 @@ namespace Serein.Library.Utils
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 文本
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static T ValueParse<T>(object value) where T : struct, IComparable<T>
|
||||
{
|
||||
string valueStr = value.ToString();
|
||||
return valueStr.ToValueData<T>() ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文本转换数值
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static object ValueParse(Type type, object value)
|
||||
{
|
||||
string valueStr = value.ToString();
|
||||
@@ -57,7 +114,13 @@ namespace Serein.Library.Utils
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 文本转换值对象
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="valueStr"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public static T ToValueData<T>(this string valueStr) where T : struct, IComparable<T>
|
||||
{
|
||||
if (string.IsNullOrEmpty(valueStr))
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -7,8 +10,13 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Library.Utils
|
||||
{
|
||||
/// <summary>
|
||||
/// 对象转换工具类
|
||||
/// </summary>
|
||||
public static class ObjectConvertHelper
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 父类转为子类
|
||||
/// </summary>
|
||||
|
||||
@@ -15,7 +15,8 @@ namespace Serein.Library.Utils
|
||||
/// </summary>
|
||||
public class UIContextOperation
|
||||
{
|
||||
private readonly SynchronizationContext context;
|
||||
private SynchronizationContext context;
|
||||
private readonly Func<SynchronizationContext> getUiContext = null;
|
||||
|
||||
static UIContextOperation()
|
||||
{
|
||||
@@ -42,12 +43,25 @@ namespace Serein.Library.Utils
|
||||
this.context = synchronizationContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 传入UI线程上下文
|
||||
/// </summary>
|
||||
/// <param name="synchronizationContext">线程上下文</param>
|
||||
public UIContextOperation(Func<SynchronizationContext> getUiContext)
|
||||
{
|
||||
this.getUiContext = getUiContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步方式进行调用方法
|
||||
/// </summary>
|
||||
/// <param name="uiAction">要执行的UI操作</param>
|
||||
public void Invoke(Action uiAction)
|
||||
{
|
||||
if(context is null && getUiContext != null)
|
||||
{
|
||||
context = getUiContext.Invoke();
|
||||
}
|
||||
context?.Post(state =>
|
||||
{
|
||||
uiAction?.Invoke();
|
||||
@@ -61,6 +75,10 @@ namespace Serein.Library.Utils
|
||||
/// <returns></returns>
|
||||
public Task InvokeAsync(Action uiAction)
|
||||
{
|
||||
if (context is null && getUiContext != null)
|
||||
{
|
||||
context = getUiContext.Invoke();
|
||||
}
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
|
||||
context?.Post(state =>
|
||||
|
||||
Reference in New Issue
Block a user