From 5bef0d9b570829ad43d73f7cef0638f9cbe97a61 Mon Sep 17 00:00:00 2001
From: fengjiayi <12821976+ning_xi@user.noreply.gitee.com>
Date: Fri, 11 Oct 2024 19:31:34 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=BA=86Library=E7=9A=84?=
=?UTF-8?q?=E6=B3=A8=E9=87=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Library/Api/IDynamicContext.cs | 4 +-
Library/Api/IDynamicFlowNode.cs | 3 +
Library/Api/IFlipflopContext.cs | 4 +-
Library/Api/ISereinIoc.cs | 57 +++++----
Library/Entity/CallChainInfo.cs | 18 ---
Library/Entity/DelegateDetails.cs | 10 +-
Library/Entity/ExplicitData.cs | 4 +-
Library/Entity/MethodDetails.cs | 114 +-----------------
Library/Entity/NodeData.cs | 10 --
Library/Entity/NodeDebugSetting.cs | 17 +--
Library/Entity/NodeLibrary.cs | 7 ++
Library/Entity/SereinProjectData.cs | 18 +--
Library/Enums/ConnectionType.cs | 6 +-
Library/Enums/FlipflopStateType.cs | 6 +-
Library/Enums/NodeType.cs | 44 ++++++-
Library/Ex/FlipflopException.cs | 20 ++-
Library/Utils/ConvertHelper.cs | 3 +
Library/Utils/EmitHelper.cs | 17 ++-
Library/Utils/EnumHelper.cs | 35 +++++-
Library/Utils/ExpressionHelper.cs | 2 +-
Library/Utils/SereinIoc.cs | 9 +-
Net462DllTest/LogicControl/PlcLogicControl.cs | 8 +-
.../LogicControl/ViewLogicControl.cs | 13 +-
Net462DllTest/Web/FlowController.cs | 2 +-
NodeFlow/FlowEnvironment.cs | 6 +-
NodeFlow/FlowStarter.cs | 2 +-
NodeFlow/Model/SingleFlipflopNode.cs | 2 +-
27 files changed, 202 insertions(+), 239 deletions(-)
delete mode 100644 Library/Entity/CallChainInfo.cs
delete mode 100644 Library/Entity/NodeData.cs
diff --git a/Library/Api/IDynamicContext.cs b/Library/Api/IDynamicContext.cs
index aabb395..31d5b74 100644
--- a/Library/Api/IDynamicContext.cs
+++ b/Library/Api/IDynamicContext.cs
@@ -5,12 +5,12 @@ using System.Threading.Tasks;
namespace Serein.Library.Api
{
///
- /// 流程上下文
+ /// 流程上下文,包含运行环境接口,可以通过注册环境事件或调用环境接口,实现在流程运行时更改流程行为。
///
public interface IDynamicContext
{
///
- /// 运行环境
+ /// 运行环境,包含IOC容器。
///
IFlowEnvironment Env { get; }
diff --git a/Library/Api/IDynamicFlowNode.cs b/Library/Api/IDynamicFlowNode.cs
index 1cf5511..683b215 100644
--- a/Library/Api/IDynamicFlowNode.cs
+++ b/Library/Api/IDynamicFlowNode.cs
@@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace Serein.Library.Api
{
+ ///
+ /// 空接口
+ ///
public interface IDynamicFlowNode
{
}
diff --git a/Library/Api/IFlipflopContext.cs b/Library/Api/IFlipflopContext.cs
index 36134f3..39cdb22 100644
--- a/Library/Api/IFlipflopContext.cs
+++ b/Library/Api/IFlipflopContext.cs
@@ -4,7 +4,9 @@ using Serein.Library.NodeFlow.Tool;
namespace Serein.Library.Api
{
///
- /// 触发器必须使用该接口作为返回值,同时必须用Task泛型表示,否则将不会进行等待触发。
+ /// 触发器必须使用该接口作为返回值,同时必须用Task泛型表示,否则将不会进行等待触发。
+ /// 即使大多数时候,触发器传出的数据可能是任何一种数据类型,导致其泛型参数可能是无意义的 object / dynamic 。
+ /// 但在确定传出类型的场景下,至少可以保证数据一定为某个类型。
///
public interface IFlipflopContext
{
diff --git a/Library/Api/ISereinIoc.cs b/Library/Api/ISereinIoc.cs
index 7f22dcc..b7491a1 100644
--- a/Library/Api/ISereinIoc.cs
+++ b/Library/Api/ISereinIoc.cs
@@ -4,19 +4,23 @@ using System.Text;
namespace Serein.Library.Api
{
+ ///
+ /// 单例模式IOC容器,内部维护了一个实例字典,默认使用类型的FullName作为Key,如果以“接口-实现类”的方式注册,那么将使用接口类型的FullName作为Key。
+ /// 当某个类型注册绑定成功后,将不会因为其它地方尝试注册相同类型的行为导致类型被重新创建。
+ ///
public interface ISereinIOC
{
///
- /// 清空
+ /// 慎用,重置IOC容器,除非再次注册绑定,否则将导致不能创建注入依赖类的临时对象。
///
///
ISereinIOC Reset();
///
- /// 注册实例
+ /// 注册实例,如果确定了params,那么将使用params入参构建实例对象。
///
ISereinIOC Register(Type type, params object[] parameters);
///
- /// 注册实例
+ /// 通过泛型的方式注册实例,如果确定了params,那么将使用params入参构建实例对象。
///
///
///
@@ -25,58 +29,65 @@ namespace Serein.Library.Api
///
/// 注册接口的实例
///
- ///
- ///
+ /// 接口类型
+ /// 实例类型
///
///
ISereinIOC Register(params object[] parameters) where TImplementation : TService;
- /////
- ///// 获取或创建并注入目标类型,会记录到IOC容器中。
- /////
- //T GetOrRegisterInstantiate();
- /////
- ///// 获取或创建并注入目标类型,会记录到IOC容器中。
- /////
- //object GetOrRegisterInstantiate(Type type);
///
- /// 获取类型的实例
+ /// 获取类型的实例。如果需要获取的类型以“接口-实现类”的方式注册,请使用接口的类型。
///
- ///
- ///
object Get(Type type);
+ ///
+ /// 获取类型的实例。如果需要获取的类型以“接口-实现类”的方式注册,请使用接口的类型。
+ ///
T Get();
///
- /// 获取指定名称的实例
+ /// 获取指定名称的实例。
+ /// 正常情况下应该使用 Get(Type type) / T Get<T>() 进行获取,但如果需要的实例是以CustomRegisterInstance()进行的登记,则需要通过这种方法进行获取。
///
///
- ///
+ /// 登记实例时使用的Key
///
T Get(string key);
///
- /// 通过名称注册实例
+ /// 指定一个Key登记一个实例。如果实例中需要注入的依赖项,需要将needInjectProperty设置为true。
///
/// 注入名称
/// 实例对象
/// 是否需要注入依赖项
- void CustomRegisterInstance(string key, object instance, bool needInjectProperty = true);
+ /// 是否注册成功
+ bool CustomRegisterInstance(string key, object instance, bool needInjectProperty = true);
///
- /// 用于临时实例的创建,不注册到IOC容器中,依赖项注入失败时也不记录。
+ /// 创建实例并注入依赖项,不会注册到IOC容器中。
+ /// 使用场景:例如 View 的构造函数中需要创建 ViewModel,而 ViewModel 存在注册过的依赖项,可以通过该接口进行创建
+ ///
///
object Instantiate(Type type);
+
///
- /// 用于临时实例的创建,不注册到IOC容器中,依赖项注入失败时也不记录。
+ /// 创建实例并注入依赖项,不会注册到IOC容器中。
+ /// 使用场景:例如 View 的构造函数中需要创建 ViewModel,而 ViewModel 存在注册过的依赖项,可以通过该接口进行创建
+ ///
///
T Instantiate();
+
///
- /// 实例化注册的类型,并注入依赖项
+ /// 通过已注册的类型,生成依赖关系,然后依次实例化并注入依赖项,最后登记到容器中。
///
///
ISereinIOC Build();
+ ///
+ /// 从容器中获取某个类型的实例进行运行
+ ///
+ ///
+ ///
+ ///
ISereinIOC Run(Action action);
ISereinIOC Run(Action action);
ISereinIOC Run(Action action);
diff --git a/Library/Entity/CallChainInfo.cs b/Library/Entity/CallChainInfo.cs
deleted file mode 100644
index fe47b13..0000000
--- a/Library/Entity/CallChainInfo.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Serein.Library.Entity
-{
- // 每次发生调用的时候,将当前节点调用信息拷贝一份,
- // 调用完成后释放?
- // 参数信息
- public class CallChainInfo
- {
- public List CallGuid { get; }
- public List