From f286fc644a298fe98e443db833e78d03600365ea Mon Sep 17 00:00:00 2001
From: fengjiayi <12821976+ning_xi@user.noreply.gitee.com>
Date: Thu, 12 Sep 2024 20:32:54 +0800
Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=86=99=E4=BA=86=E8=8A=82=E7=82=B9?=
=?UTF-8?q?=E7=9A=84view=E3=80=81viewmodel=E5=85=B3=E7=B3=BB=EF=BC=8C?=
=?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BA=86=E5=AF=B9=E7=94=BB=E5=B8=83=E5=85=83?=
=?UTF-8?q?=E7=B4=A0=E7=9A=84=E9=80=89=E5=8F=96=E5=8A=9F=E8=83=BD=EF=BC=8C?=
=?UTF-8?q?=E9=87=8D=E6=9E=84=E4=BA=86=E5=BA=95=E5=B1=82=E4=BE=9D=E8=B5=96?=
=?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=BA=86=E5=AF=B9net=20.Framework4.?=
=?UTF-8?q?6.1=E4=BB=A5=E4=B8=8A=E7=9A=84Framework=E7=B1=BB=E5=BA=93?=
=?UTF-8?q?=E6=94=AF=E6=8C=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
{Library => Library.Core}/DbSql/DBSync.cs | 0
.../DbSql/FifoManualResetEvent.cs | 0
.../DbSql/IRepositoryBase.cs | 0
.../DbSql/RepositoryBase.cs | 0
{Library => Library.Core}/Flow/Api.cs | 0
{Library => Library.Core}/Flow/Attribute.cs | 0
.../Flow/DynamicContext.cs | 0
.../Flow/MethodDetails.cs | 0
.../Flow/NodeFlowStarter.cs | 0
.../Flow/NodeModel/CompositeActionNode.cs | 0
.../Flow/NodeModel/CompositeConditionNode.cs | 0
.../Flow/NodeModel/CompositeLoopNode.cs | 0
.../Flow/NodeModel/NodeBase.cs | 0
.../Flow/NodeModel/SingleActionNode.cs | 0
.../Flow/NodeModel/SingleConditionNode.cs | 0
.../Flow/NodeModel/SingleExpOpNode.cs | 0
.../Flow/NodeModel/SingleFlipflopNode.cs | 0
.../Flow/SerinExpression/ConditionResolver.cs | 0
.../SerinExpression/SerinConditionParser.cs | 0
.../SerinExpressionEvaluator.cs | 0
.../Flow/Tool/DelegateGenerator.cs | 0
.../Flow/Tool/DynamicTool.cs | 0
.../Flow/Tool/ExpressionHelper.cs | 0
.../Flow/Tool/TcsSignal.cs | 0
{Library => Library.Core}/Http/Attribute.cs | 3 +-
.../Http/ControllerBase.cs | 4 +-
{Library => Library.Core}/Http/Router.cs | 14 +-
.../Http/WebAPIAttribute.cs | 8 +-
.../IOC/SereinIoc.cs | 70 +-
Library.Core/NodeFlow/DynamicContext.cs | 35 +
Library.Core/NodeFlow/DynamicNodeCoreType.cs | 38 +
Library.Core/NodeFlow/FlipflopContext.cs | 85 +
Library.Core/NodeFlow/FlowStateType.cs | 25 +
Library.Core/NodeFlow/Tool/Attribute.cs | 35 +
Library.Core/NodeFlow/Tool/DynamicTool.cs | 202 +
Library.Core/Serein.Library.Core.csproj | 52 +
.../SerinExpression/ConditionResolver.cs | 2 +-
.../SerinExpression/SerinConditionParser.cs | 3 +-
.../SerinExpressionEvaluator.cs | 15 +-
{Library => Library.Core}/ServiceContainer.cs | 0
{Library => Library.Core}/Tool/DataHelper.cs | 0
Library.Framework/Http/Attribute.cs | 167 +
Library.Framework/Http/ControllerBase.cs | 19 +
Library.Framework/Http/Router.cs | 761 ++
Library.Framework/Http/WebAPIAttribute.cs | 196 +
Library.Framework/IOC/SereinIoc.cs | 378 +
Library.Framework/NodeFlow/Api.cs | 13 +
Library.Framework/NodeFlow/DynamicContext.cs | 40 +
.../NodeFlow/DynamicNodeFrameworkType.cs | 38 +
Library.Framework/NodeFlow/FlipflopContext.cs | 94 +
Library.Framework/NodeFlow/FlowStateType.cs | 25 +
Library.Framework/NodeFlow/Tool/Attribute.cs | 8 +
.../NodeFlow/Tool/DynamicTool.cs | 194 +
Library.Framework/NodeFlow/Tool/TcsSignal.cs | 65 +
Library.Framework/Properties/AssemblyInfo.cs | 36 +
.../Serein.Library.Framework.csproj | 63 +
Library.Framework/Tool/DataHelper.cs | 186 +
Library.Framework/packages.config | 4 +
Library/Api/IDynamicContext.cs | 13 +
Library/Api/IFlipflopContext.cs | 10 +
Library/Api/ISereinIoc.cs | 36 +
Library/Enums/FlowStateType.cs | 25 +
Library/Enums/NodeType.cs | 38 +
Library/NodeAttribute.cs | 49 +
Library/Serein.Library.csproj | 23 +-
Library/Utils/SereinIoc.cs | 378 +
Library/Utils/TcsSignal.cs | 64 +
Library/Utils/Utils.cs | 9 +
MyDll/SampleCondition.cs | 111 +-
NodeFlow/DynamicContext.cs | 83 +-
NodeFlow/DynamicNodeFrameworkType.cs | 38 +
NodeFlow/FlowStateType.cs | 24 +
NodeFlow/MethodDetails.cs | 161 +-
NodeFlow/Model/CompositeConditionNode.cs | 10 +-
NodeFlow/Model/NodeBase.cs | 134 +-
NodeFlow/Model/SingleConditionNode.cs | 7 +-
NodeFlow/Model/SingleExpOpNode.cs | 13 +-
NodeFlow/Model/SingleFlipflopNode.cs | 5 +-
NodeFlow/NodeFlowStarter.cs | 46 +-
NodeFlow/Serein - Backup.NodeFlow.csproj | 36 +
NodeFlow/Serein.NodeFlow.csproj | 13 +
NodeFlow/{ => Tool}/Attribute.cs | 2 +-
NodeFlow/Tool/DelegateGenerator.cs | 86 +-
NodeFlow/Tool/ExpressionHelper.cs | 27 +-
.../Tool/SerinExpression/ConditionResolver.cs | 337 +
.../SerinExpression/SerinConditionParser.cs | 341 +
.../SerinExpressionEvaluator.cs | 216 +
NodeFlow/Tool/TcsSignal.cs | 33 +-
SereinFlow.sln | 20 +-
SereinWAT/SereinWAT.cs | 1 +
WorkBench/App.xaml.cs | 2 +-
WorkBench/MainWindow.xaml | 12 +
WorkBench/MainWindow.xaml.cs | 465 +-
WorkBench/Node/View/ActionNodeControl.xaml.cs | 10 +-
.../Node/View/ActionRegionControl.xaml.cs | 23 +-
.../Node/View/ConditionNodeControl.xaml.cs | 13 +-
.../Node/View/ConditionRegionControl.xaml | 5 -
.../Node/View/ConditionRegionControl.xaml.cs | 51 +-
WorkBench/Node/View/ExpOpNodeControl.xaml.cs | 14 +-
.../Node/View/FlipflopNodeControl.xaml.cs | 23 +-
WorkBench/Node/View/NodeControlBase.cs | 25 +-
.../ViewModel/ActionNodeControlViewModel.cs | 17 +-
.../ConditionNodeControlViewModel.cs | 5 +-
.../ConditionRegionNodeControlViewModel.cs | 18 +
.../Node/ViewModel/ExpOpNodeViewModel.cs | 4 +-
.../ViewModel/FlipflopNodeControlViewModel.cs | 5 +-
WorkBench/Serein.WorkBench.csproj | 4 +-
.../Newtonsoft.Json.13.0.3/.signature.p7s | Bin 0 -> 24497 bytes
packages/Newtonsoft.Json.13.0.3/LICENSE.md | 20 +
.../Newtonsoft.Json.13.0.3.nupkg | Bin 0 -> 2441966 bytes
packages/Newtonsoft.Json.13.0.3/README.md | 71 +
.../lib/net20/Newtonsoft.Json.xml | 10393 ++++++++++++++
.../lib/net35/Newtonsoft.Json.xml | 9541 +++++++++++++
.../lib/net40/Newtonsoft.Json.xml | 9741 +++++++++++++
.../lib/net45/Newtonsoft.Json.xml | 11363 ++++++++++++++++
.../lib/net6.0/Newtonsoft.Json.xml | 11325 +++++++++++++++
.../lib/netstandard1.0/Newtonsoft.Json.xml | 11051 +++++++++++++++
.../lib/netstandard1.3/Newtonsoft.Json.xml | 11173 +++++++++++++++
.../lib/netstandard2.0/Newtonsoft.Json.xml | 11338 +++++++++++++++
.../Newtonsoft.Json.13.0.3/packageIcon.png | Bin 0 -> 8956 bytes
120 files changed, 91218 insertions(+), 761 deletions(-)
rename {Library => Library.Core}/DbSql/DBSync.cs (100%)
rename {Library => Library.Core}/DbSql/FifoManualResetEvent.cs (100%)
rename {Library => Library.Core}/DbSql/IRepositoryBase.cs (100%)
rename {Library => Library.Core}/DbSql/RepositoryBase.cs (100%)
rename {Library => Library.Core}/Flow/Api.cs (100%)
rename {Library => Library.Core}/Flow/Attribute.cs (100%)
rename {Library => Library.Core}/Flow/DynamicContext.cs (100%)
rename {Library => Library.Core}/Flow/MethodDetails.cs (100%)
rename {Library => Library.Core}/Flow/NodeFlowStarter.cs (100%)
rename {Library => Library.Core}/Flow/NodeModel/CompositeActionNode.cs (100%)
rename {Library => Library.Core}/Flow/NodeModel/CompositeConditionNode.cs (100%)
rename {Library => Library.Core}/Flow/NodeModel/CompositeLoopNode.cs (100%)
rename {Library => Library.Core}/Flow/NodeModel/NodeBase.cs (100%)
rename {Library => Library.Core}/Flow/NodeModel/SingleActionNode.cs (100%)
rename {Library => Library.Core}/Flow/NodeModel/SingleConditionNode.cs (100%)
rename {Library => Library.Core}/Flow/NodeModel/SingleExpOpNode.cs (100%)
rename {Library => Library.Core}/Flow/NodeModel/SingleFlipflopNode.cs (100%)
rename {Library => Library.Core}/Flow/SerinExpression/ConditionResolver.cs (100%)
rename {Library => Library.Core}/Flow/SerinExpression/SerinConditionParser.cs (100%)
rename {Library => Library.Core}/Flow/SerinExpression/SerinExpressionEvaluator.cs (100%)
rename {Library => Library.Core}/Flow/Tool/DelegateGenerator.cs (100%)
rename {Library => Library.Core}/Flow/Tool/DynamicTool.cs (100%)
rename {Library => Library.Core}/Flow/Tool/ExpressionHelper.cs (100%)
rename {Library => Library.Core}/Flow/Tool/TcsSignal.cs (100%)
rename {Library => Library.Core}/Http/Attribute.cs (98%)
rename {Library => Library.Core}/Http/ControllerBase.cs (90%)
rename {Library => Library.Core}/Http/Router.cs (98%)
rename {Library => Library.Core}/Http/WebAPIAttribute.cs (97%)
rename Library/IOC/ServiceContainer.cs => Library.Core/IOC/SereinIoc.cs (79%)
create mode 100644 Library.Core/NodeFlow/DynamicContext.cs
create mode 100644 Library.Core/NodeFlow/DynamicNodeCoreType.cs
create mode 100644 Library.Core/NodeFlow/FlipflopContext.cs
create mode 100644 Library.Core/NodeFlow/FlowStateType.cs
create mode 100644 Library.Core/NodeFlow/Tool/Attribute.cs
create mode 100644 Library.Core/NodeFlow/Tool/DynamicTool.cs
create mode 100644 Library.Core/Serein.Library.Core.csproj
rename {Library => Library.Core}/SerinExpression/ConditionResolver.cs (99%)
rename {Library => Library.Core}/SerinExpression/SerinConditionParser.cs (99%)
rename {Library => Library.Core}/SerinExpression/SerinExpressionEvaluator.cs (92%)
rename {Library => Library.Core}/ServiceContainer.cs (100%)
rename {Library => Library.Core}/Tool/DataHelper.cs (100%)
create mode 100644 Library.Framework/Http/Attribute.cs
create mode 100644 Library.Framework/Http/ControllerBase.cs
create mode 100644 Library.Framework/Http/Router.cs
create mode 100644 Library.Framework/Http/WebAPIAttribute.cs
create mode 100644 Library.Framework/IOC/SereinIoc.cs
create mode 100644 Library.Framework/NodeFlow/Api.cs
create mode 100644 Library.Framework/NodeFlow/DynamicContext.cs
create mode 100644 Library.Framework/NodeFlow/DynamicNodeFrameworkType.cs
create mode 100644 Library.Framework/NodeFlow/FlipflopContext.cs
create mode 100644 Library.Framework/NodeFlow/FlowStateType.cs
create mode 100644 Library.Framework/NodeFlow/Tool/Attribute.cs
create mode 100644 Library.Framework/NodeFlow/Tool/DynamicTool.cs
create mode 100644 Library.Framework/NodeFlow/Tool/TcsSignal.cs
create mode 100644 Library.Framework/Properties/AssemblyInfo.cs
create mode 100644 Library.Framework/Serein.Library.Framework.csproj
create mode 100644 Library.Framework/Tool/DataHelper.cs
create mode 100644 Library.Framework/packages.config
create mode 100644 Library/Api/IDynamicContext.cs
create mode 100644 Library/Api/IFlipflopContext.cs
create mode 100644 Library/Api/ISereinIoc.cs
create mode 100644 Library/Enums/FlowStateType.cs
create mode 100644 Library/Enums/NodeType.cs
create mode 100644 Library/NodeAttribute.cs
create mode 100644 Library/Utils/SereinIoc.cs
create mode 100644 Library/Utils/TcsSignal.cs
create mode 100644 Library/Utils/Utils.cs
create mode 100644 NodeFlow/DynamicNodeFrameworkType.cs
create mode 100644 NodeFlow/FlowStateType.cs
create mode 100644 NodeFlow/Serein - Backup.NodeFlow.csproj
rename NodeFlow/{ => Tool}/Attribute.cs (98%)
create mode 100644 NodeFlow/Tool/SerinExpression/ConditionResolver.cs
create mode 100644 NodeFlow/Tool/SerinExpression/SerinConditionParser.cs
create mode 100644 NodeFlow/Tool/SerinExpression/SerinExpressionEvaluator.cs
create mode 100644 WorkBench/Node/ViewModel/ConditionRegionNodeControlViewModel.cs
create mode 100644 packages/Newtonsoft.Json.13.0.3/.signature.p7s
create mode 100644 packages/Newtonsoft.Json.13.0.3/LICENSE.md
create mode 100644 packages/Newtonsoft.Json.13.0.3/Newtonsoft.Json.13.0.3.nupkg
create mode 100644 packages/Newtonsoft.Json.13.0.3/README.md
create mode 100644 packages/Newtonsoft.Json.13.0.3/lib/net20/Newtonsoft.Json.xml
create mode 100644 packages/Newtonsoft.Json.13.0.3/lib/net35/Newtonsoft.Json.xml
create mode 100644 packages/Newtonsoft.Json.13.0.3/lib/net40/Newtonsoft.Json.xml
create mode 100644 packages/Newtonsoft.Json.13.0.3/lib/net45/Newtonsoft.Json.xml
create mode 100644 packages/Newtonsoft.Json.13.0.3/lib/net6.0/Newtonsoft.Json.xml
create mode 100644 packages/Newtonsoft.Json.13.0.3/lib/netstandard1.0/Newtonsoft.Json.xml
create mode 100644 packages/Newtonsoft.Json.13.0.3/lib/netstandard1.3/Newtonsoft.Json.xml
create mode 100644 packages/Newtonsoft.Json.13.0.3/lib/netstandard2.0/Newtonsoft.Json.xml
create mode 100644 packages/Newtonsoft.Json.13.0.3/packageIcon.png
diff --git a/Library/DbSql/DBSync.cs b/Library.Core/DbSql/DBSync.cs
similarity index 100%
rename from Library/DbSql/DBSync.cs
rename to Library.Core/DbSql/DBSync.cs
diff --git a/Library/DbSql/FifoManualResetEvent.cs b/Library.Core/DbSql/FifoManualResetEvent.cs
similarity index 100%
rename from Library/DbSql/FifoManualResetEvent.cs
rename to Library.Core/DbSql/FifoManualResetEvent.cs
diff --git a/Library/DbSql/IRepositoryBase.cs b/Library.Core/DbSql/IRepositoryBase.cs
similarity index 100%
rename from Library/DbSql/IRepositoryBase.cs
rename to Library.Core/DbSql/IRepositoryBase.cs
diff --git a/Library/DbSql/RepositoryBase.cs b/Library.Core/DbSql/RepositoryBase.cs
similarity index 100%
rename from Library/DbSql/RepositoryBase.cs
rename to Library.Core/DbSql/RepositoryBase.cs
diff --git a/Library/Flow/Api.cs b/Library.Core/Flow/Api.cs
similarity index 100%
rename from Library/Flow/Api.cs
rename to Library.Core/Flow/Api.cs
diff --git a/Library/Flow/Attribute.cs b/Library.Core/Flow/Attribute.cs
similarity index 100%
rename from Library/Flow/Attribute.cs
rename to Library.Core/Flow/Attribute.cs
diff --git a/Library/Flow/DynamicContext.cs b/Library.Core/Flow/DynamicContext.cs
similarity index 100%
rename from Library/Flow/DynamicContext.cs
rename to Library.Core/Flow/DynamicContext.cs
diff --git a/Library/Flow/MethodDetails.cs b/Library.Core/Flow/MethodDetails.cs
similarity index 100%
rename from Library/Flow/MethodDetails.cs
rename to Library.Core/Flow/MethodDetails.cs
diff --git a/Library/Flow/NodeFlowStarter.cs b/Library.Core/Flow/NodeFlowStarter.cs
similarity index 100%
rename from Library/Flow/NodeFlowStarter.cs
rename to Library.Core/Flow/NodeFlowStarter.cs
diff --git a/Library/Flow/NodeModel/CompositeActionNode.cs b/Library.Core/Flow/NodeModel/CompositeActionNode.cs
similarity index 100%
rename from Library/Flow/NodeModel/CompositeActionNode.cs
rename to Library.Core/Flow/NodeModel/CompositeActionNode.cs
diff --git a/Library/Flow/NodeModel/CompositeConditionNode.cs b/Library.Core/Flow/NodeModel/CompositeConditionNode.cs
similarity index 100%
rename from Library/Flow/NodeModel/CompositeConditionNode.cs
rename to Library.Core/Flow/NodeModel/CompositeConditionNode.cs
diff --git a/Library/Flow/NodeModel/CompositeLoopNode.cs b/Library.Core/Flow/NodeModel/CompositeLoopNode.cs
similarity index 100%
rename from Library/Flow/NodeModel/CompositeLoopNode.cs
rename to Library.Core/Flow/NodeModel/CompositeLoopNode.cs
diff --git a/Library/Flow/NodeModel/NodeBase.cs b/Library.Core/Flow/NodeModel/NodeBase.cs
similarity index 100%
rename from Library/Flow/NodeModel/NodeBase.cs
rename to Library.Core/Flow/NodeModel/NodeBase.cs
diff --git a/Library/Flow/NodeModel/SingleActionNode.cs b/Library.Core/Flow/NodeModel/SingleActionNode.cs
similarity index 100%
rename from Library/Flow/NodeModel/SingleActionNode.cs
rename to Library.Core/Flow/NodeModel/SingleActionNode.cs
diff --git a/Library/Flow/NodeModel/SingleConditionNode.cs b/Library.Core/Flow/NodeModel/SingleConditionNode.cs
similarity index 100%
rename from Library/Flow/NodeModel/SingleConditionNode.cs
rename to Library.Core/Flow/NodeModel/SingleConditionNode.cs
diff --git a/Library/Flow/NodeModel/SingleExpOpNode.cs b/Library.Core/Flow/NodeModel/SingleExpOpNode.cs
similarity index 100%
rename from Library/Flow/NodeModel/SingleExpOpNode.cs
rename to Library.Core/Flow/NodeModel/SingleExpOpNode.cs
diff --git a/Library/Flow/NodeModel/SingleFlipflopNode.cs b/Library.Core/Flow/NodeModel/SingleFlipflopNode.cs
similarity index 100%
rename from Library/Flow/NodeModel/SingleFlipflopNode.cs
rename to Library.Core/Flow/NodeModel/SingleFlipflopNode.cs
diff --git a/Library/Flow/SerinExpression/ConditionResolver.cs b/Library.Core/Flow/SerinExpression/ConditionResolver.cs
similarity index 100%
rename from Library/Flow/SerinExpression/ConditionResolver.cs
rename to Library.Core/Flow/SerinExpression/ConditionResolver.cs
diff --git a/Library/Flow/SerinExpression/SerinConditionParser.cs b/Library.Core/Flow/SerinExpression/SerinConditionParser.cs
similarity index 100%
rename from Library/Flow/SerinExpression/SerinConditionParser.cs
rename to Library.Core/Flow/SerinExpression/SerinConditionParser.cs
diff --git a/Library/Flow/SerinExpression/SerinExpressionEvaluator.cs b/Library.Core/Flow/SerinExpression/SerinExpressionEvaluator.cs
similarity index 100%
rename from Library/Flow/SerinExpression/SerinExpressionEvaluator.cs
rename to Library.Core/Flow/SerinExpression/SerinExpressionEvaluator.cs
diff --git a/Library/Flow/Tool/DelegateGenerator.cs b/Library.Core/Flow/Tool/DelegateGenerator.cs
similarity index 100%
rename from Library/Flow/Tool/DelegateGenerator.cs
rename to Library.Core/Flow/Tool/DelegateGenerator.cs
diff --git a/Library/Flow/Tool/DynamicTool.cs b/Library.Core/Flow/Tool/DynamicTool.cs
similarity index 100%
rename from Library/Flow/Tool/DynamicTool.cs
rename to Library.Core/Flow/Tool/DynamicTool.cs
diff --git a/Library/Flow/Tool/ExpressionHelper.cs b/Library.Core/Flow/Tool/ExpressionHelper.cs
similarity index 100%
rename from Library/Flow/Tool/ExpressionHelper.cs
rename to Library.Core/Flow/Tool/ExpressionHelper.cs
diff --git a/Library/Flow/Tool/TcsSignal.cs b/Library.Core/Flow/Tool/TcsSignal.cs
similarity index 100%
rename from Library/Flow/Tool/TcsSignal.cs
rename to Library.Core/Flow/Tool/TcsSignal.cs
diff --git a/Library/Http/Attribute.cs b/Library.Core/Http/Attribute.cs
similarity index 98%
rename from Library/Http/Attribute.cs
rename to Library.Core/Http/Attribute.cs
index 80c9f20..670a840 100644
--- a/Library/Http/Attribute.cs
+++ b/Library.Core/Http/Attribute.cs
@@ -1,6 +1,6 @@
using System;
-namespace Serein.Library.Http
+namespace Serein.Library.Core.Http
{
///
/// 表示参数为url中的数据(Get请求中不需要显式标注)
@@ -96,6 +96,7 @@ namespace Serein.Library.Http
///
public bool IsUrl = true;
}
+
/*public sealed class WebApiAttribute(API http, bool isUrl = true, string url = "") : Attribute
{
public API Http { get; } = http;
diff --git a/Library/Http/ControllerBase.cs b/Library.Core/Http/ControllerBase.cs
similarity index 90%
rename from Library/Http/ControllerBase.cs
rename to Library.Core/Http/ControllerBase.cs
index 812d684..714c1a0 100644
--- a/Library/Http/ControllerBase.cs
+++ b/Library.Core/Http/ControllerBase.cs
@@ -1,14 +1,12 @@
-namespace Serein.Library.Http
+namespace Serein.Library.Core.Http
{
public class ControllerBase
{
public string Url { get; set; }
-
public string BobyData { get; set; }
-
public string GetLog(Exception ex)
{
return "Url : " + Url + Environment.NewLine +
diff --git a/Library/Http/Router.cs b/Library.Core/Http/Router.cs
similarity index 98%
rename from Library/Http/Router.cs
rename to Library.Core/Http/Router.cs
index 6abb23d..61ad03b 100644
--- a/Library/Http/Router.cs
+++ b/Library.Core/Http/Router.cs
@@ -1,10 +1,10 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
-using Serein.Library.IOC;
+using Serein.Library.Api.Api;
+using Serein.Library.Core.IOC;
using Serein.Tool;
using System.Collections;
using System.Collections.Concurrent;
-using System.Collections.Generic;
using System.Net;
using System.Reflection;
using System.Text;
@@ -12,7 +12,7 @@ using System.Web;
using Enum = System.Enum;
using Type = System.Type;
-namespace Serein.Library.Http
+namespace Serein.Library.Core.Http
{
@@ -28,11 +28,11 @@ namespace Serein.Library.Http
private readonly ConcurrentDictionary _controllerInstances; // 存储控制器实例对象
private readonly ConcurrentDictionary> _routes; // 用于存储路由信息
- private readonly IServiceContainer serviceRegistry; // 用于存储路由信息
+ private readonly ISereinIoc serviceRegistry; // 用于存储路由信息
//private Type PostRequest;
- public Router(IServiceContainer serviceRegistry) // 构造函数,初始化 Router 类的新实例
+ public Router(ISereinIoc serviceRegistry) // 构造函数,初始化 Router 类的新实例
{
this.serviceRegistry = serviceRegistry;
@@ -172,7 +172,7 @@ namespace Serein.Library.Http
/// 手动注册 实例持久控制器实例
///
///
- public void RegisterController(T controllerInstance) // 方法声明,用于动态注册路由
+ public void RegisterController(TController controllerInstance) where TController : ControllerBase // 方法声明,用于动态注册路由
{
if(controllerInstance == null) return;
Type controllerType = controllerInstance.GetType(); // 获取控制器实例的类型
@@ -286,6 +286,8 @@ namespace Serein.Library.Http
}
}
}
+
+
///
/// 解析路由,调用对应的方法
///
diff --git a/Library/Http/WebAPIAttribute.cs b/Library.Core/Http/WebAPIAttribute.cs
similarity index 97%
rename from Library/Http/WebAPIAttribute.cs
rename to Library.Core/Http/WebAPIAttribute.cs
index 2e334e2..7973e4c 100644
--- a/Library/Http/WebAPIAttribute.cs
+++ b/Library.Core/Http/WebAPIAttribute.cs
@@ -1,9 +1,9 @@
-using Serein.Library.IOC;
+using Serein.Library.Api.Api;
+using Serein.Library.Core.IOC;
using System.Collections.Concurrent;
using System.Net;
-using System.Security.AccessControl;
-namespace Serein.Library.Http
+namespace Serein.Library.Core.Http
{
///
@@ -27,7 +27,7 @@ namespace Serein.Library.Http
}
// 启动服务器
- public WebServer Start(string prefixe, IServiceContainer serviceContainer)
+ public WebServer Start(string prefixe, ISereinIoc serviceContainer)
{
try
{
diff --git a/Library/IOC/ServiceContainer.cs b/Library.Core/IOC/SereinIoc.cs
similarity index 79%
rename from Library/IOC/ServiceContainer.cs
rename to Library.Core/IOC/SereinIoc.cs
index 92a83bc..63eea9a 100644
--- a/Library/IOC/ServiceContainer.cs
+++ b/Library.Core/IOC/SereinIoc.cs
@@ -1,54 +1,23 @@
-using Serein.Library.Http;
-using SqlSugar;
+using Serein.Library.Api;
+using Serein.Library.Attributes;
using System.Collections.Concurrent;
using System.Reflection;
-namespace Serein.Library.IOC
+namespace Serein.Library.Core.IOC
{
-
-
- public interface IServiceContainer
- {
- ///
- /// 获取或创建类型的实例(不注入依赖项)
- ///
- object GetOrCreateServiceInstance(Type serviceType, params object[] parameters);
- T CreateServiceInstance(params object[] parameters);
- IServiceContainer Reset(); // 清空
- IServiceContainer Register(Type type, params object[] parameters);
- IServiceContainer Register(params object[] parameters);
- IServiceContainer Register(params object[] parameters) where TImplementation : TService;
- T GetOrInstantiate();
- object GetOrInstantiate(Type type);
-
- ///
- /// 创建目标类型的对象, 并注入依赖项
- ///
- object? Instantiate(Type type, params object[] parameters);
- IServiceContainer Build();
- IServiceContainer Run(Action action);
- IServiceContainer Run(Action action);
- IServiceContainer Run(Action action);
- IServiceContainer Run(Action action);
- IServiceContainer Run(Action action);
- IServiceContainer Run(Action action);
- IServiceContainer Run(Action action);
- IServiceContainer Run(Action action);
- }
-
- public class ServiceContainer : IServiceContainer
+ public class SereinIoc : ISereinIoc
{
private readonly ConcurrentDictionary _dependencies;
private readonly ConcurrentDictionary _typeMappings;
private readonly List _waitingForInstantiation;
- public ServiceContainer()
+ public SereinIoc()
{
_dependencies = new ConcurrentDictionary
{
- [typeof(IServiceContainer).FullName] = this
+ [typeof(ISereinIoc).FullName] = this
};
_typeMappings = new ConcurrentDictionary();
@@ -75,14 +44,13 @@ namespace Serein.Library.IOC
return instance;
-
}
public T CreateServiceInstance(params object[] parameters)
{
return (T)GetOrCreateServiceInstance(typeof(T), parameters);
}
- public IServiceContainer Reset()
+ public ISereinIoc Reset()
{
foreach(var instancei in _dependencies.Values)
{
@@ -97,7 +65,7 @@ namespace Serein.Library.IOC
return this;
}
- public IServiceContainer Register(Type type, params object[] parameters)
+ public ISereinIoc Register(Type type, params object[] parameters)
{
if (!_typeMappings.ContainsKey(type.FullName))
@@ -107,13 +75,13 @@ namespace Serein.Library.IOC
return this;
}
- public IServiceContainer Register(params object[] parameters)
+ public ISereinIoc Register(params object[] parameters)
{
Register(typeof(T), parameters);
return this;
}
- public IServiceContainer Register(params object[] parameters)
+ public ISereinIoc Register(params object[] parameters)
where TImplementation : TService
{
_typeMappings[typeof(TService).FullName!] = typeof(TImplementation);
@@ -152,7 +120,7 @@ namespace Serein.Library.IOC
return (T)value;
//throw new InvalidOperationException("目标类型未创建实例");
}
- public IServiceContainer Build()
+ public ISereinIoc Build()
{
foreach (var type in _typeMappings.Values)
{
@@ -224,7 +192,7 @@ namespace Serein.Library.IOC
}
#region run()
- public IServiceContainer Run(Action action)
+ public ISereinIoc Run(Action action)
{
var service = GetOrInstantiate();
if (service != null)
@@ -234,7 +202,7 @@ namespace Serein.Library.IOC
return this;
}
- public IServiceContainer Run(Action action)
+ public ISereinIoc Run(Action action)
{
var service1 = GetOrInstantiate();
var service2 = GetOrInstantiate();
@@ -243,7 +211,7 @@ namespace Serein.Library.IOC
return this;
}
- public IServiceContainer Run(Action action)
+ public ISereinIoc Run(Action action)
{
var service1 = GetOrInstantiate();
var service2 = GetOrInstantiate();
@@ -252,7 +220,7 @@ namespace Serein.Library.IOC
return this;
}
- public IServiceContainer Run(Action action)
+ public ISereinIoc Run(Action action)
{
var service1 = GetOrInstantiate();
var service2 = GetOrInstantiate();
@@ -262,7 +230,7 @@ namespace Serein.Library.IOC
return this;
}
- public IServiceContainer Run(Action action)
+ public ISereinIoc Run(Action action)
{
var service1 = GetOrInstantiate();
var service2 = GetOrInstantiate();
@@ -273,7 +241,7 @@ namespace Serein.Library.IOC
return this;
}
- public IServiceContainer Run(Action action)
+ public ISereinIoc Run(Action action)
{
var service1 = GetOrInstantiate();
var service2 = GetOrInstantiate();
@@ -285,7 +253,7 @@ namespace Serein.Library.IOC
return this;
}
- public IServiceContainer Run(Action action)
+ public ISereinIoc Run(Action action)
{
var service1 = GetOrInstantiate();
var service2 = GetOrInstantiate();
@@ -298,7 +266,7 @@ namespace Serein.Library.IOC
return this;
}
- public IServiceContainer Run(Action action)
+ public ISereinIoc Run(Action action)
{
var service1 = GetOrInstantiate();
var service2 = GetOrInstantiate();
diff --git a/Library.Core/NodeFlow/DynamicContext.cs b/Library.Core/NodeFlow/DynamicContext.cs
new file mode 100644
index 0000000..5e9020d
--- /dev/null
+++ b/Library.Core/NodeFlow/DynamicContext.cs
@@ -0,0 +1,35 @@
+using Serein.Library.Api;
+using Serein.Library.Utils;
+
+namespace Serein.Library.Core.NodeFlow
+{
+
+ ///
+ /// 动态流程上下文
+ ///
+ public class DynamicContext: IDynamicContext
+ {
+ public DynamicContext(ISereinIoc sereinIoc)
+ {
+ SereinIoc = sereinIoc;
+ }
+
+ public NodeRunCts NodeRunCts { get; set; }
+ public ISereinIoc SereinIoc { get; }
+ public Task CreateTimingTask(Action action, int time = 100, int count = -1)
+ {
+ NodeRunCts ??= SereinIoc.GetOrInstantiate();
+ return Task.Factory.StartNew(async () =>
+ {
+ for (int i = 0; i < count; i++)
+ {
+ NodeRunCts.Token.ThrowIfCancellationRequested();
+ await Task.Delay(time);
+ action.Invoke();
+ }
+ });
+ }
+ }
+
+
+}
diff --git a/Library.Core/NodeFlow/DynamicNodeCoreType.cs b/Library.Core/NodeFlow/DynamicNodeCoreType.cs
new file mode 100644
index 0000000..e97d99f
--- /dev/null
+++ b/Library.Core/NodeFlow/DynamicNodeCoreType.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Serein.LibraryCore.NodeFlow
+{
+ public enum DynamicNodeCoreType
+ {
+ ///
+ /// 初始化
+ ///
+ Init,
+ ///
+ /// 开始载入
+ ///
+ Loading,
+ ///
+ /// 结束
+ ///
+ Exit,
+
+ ///
+ /// 触发器
+ ///
+ Flipflop,
+ ///
+ /// 条件节点
+ ///
+ Condition,
+ ///
+ /// 动作节点
+ ///
+ Action,
+ }
+
+}
diff --git a/Library.Core/NodeFlow/FlipflopContext.cs b/Library.Core/NodeFlow/FlipflopContext.cs
new file mode 100644
index 0000000..81c0e1b
--- /dev/null
+++ b/Library.Core/NodeFlow/FlipflopContext.cs
@@ -0,0 +1,85 @@
+using Serein.Library.Api;
+using Serein.Library.Enums;
+
+namespace Serein.Library.Core.NodeFlow
+{
+ public static class FlipflopFunc
+ {
+ ///
+ /// 传入触发器方法的返回类型,尝试获取Task[Flipflop[]] 中的泛型类型
+ ///
+ //public static Type GetFlipflopInnerType(Type type)
+ //{
+ // // 检查是否为泛型类型且为 Task<>
+ // if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Task<>))
+ // {
+ // // 获取 Task<> 的泛型参数类型,即 Flipflop<>
+ // var innerType = type.GetGenericArguments()[0];
+
+ // // 检查泛型参数是否为 Flipflop<>
+ // if (innerType.IsGenericType && innerType.GetGenericTypeDefinition() == typeof(FlipflopContext<>))
+ // {
+ // // 获取 Flipflop<> 的泛型参数类型,即 T
+ // var flipflopInnerType = innerType.GetGenericArguments()[0];
+
+ // // 返回 Flipflop<> 中的具体类型
+ // return flipflopInnerType;
+ // }
+ // }
+ // // 如果不符合条件,返回 null
+ // return null;
+ //}
+
+ public static bool IsTaskOfFlipflop(Type type)
+ {
+ // 检查是否为泛型类型且为 Task<>
+ if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Task<>))
+ {
+ // 获取 Task<> 的泛型参数类型
+ var innerType = type.GetGenericArguments()[0];
+
+ // 判断 innerType 是否继承 IFlipflopContext
+ //if (typeof(IFlipflopContext).IsAssignableFrom(innerType))
+ //{
+ // return true;
+ //}
+ //else
+ //{
+ // return false;
+ //}
+
+ // 检查泛型参数是否为 Flipflop<>
+ if (innerType == typeof(IFlipflopContext))
+ //if (innerType.IsGenericType && innerType.GetGenericTypeDefinition() == typeof(FlipflopContext<>))
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+
+ ///
+ /// 触发器上下文
+ ///
+ public class FlipflopContext : IFlipflopContext
+ {
+ public FlowStateType State { get; set; }
+ //public TResult? Data { get; set; }
+ public object Data { get; set; }
+
+ public FlipflopContext(FlowStateType ffState)
+ {
+ State = ffState;
+ }
+ public FlipflopContext(FlowStateType ffState, object data)
+ {
+ State = ffState;
+ Data = data;
+ }
+
+
+ }
+
+}
diff --git a/Library.Core/NodeFlow/FlowStateType.cs b/Library.Core/NodeFlow/FlowStateType.cs
new file mode 100644
index 0000000..aae089c
--- /dev/null
+++ b/Library.Core/NodeFlow/FlowStateType.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Serein.Library.Core.NodeFlow
+{
+
+ //public enum FlowStateType
+ //{
+ // ///
+ // /// 成功(方法成功执行)
+ // ///
+ // Succeed,
+ // ///
+ // /// 失败(方法没有成功执行,不过执行时没有发生非预期的错误)
+ // ///
+ // Fail,
+ // ///
+ // /// 异常(节点没有成功执行,执行时发生非预期的错误)
+ // ///
+ // Error,
+ //}
+}
diff --git a/Library.Core/NodeFlow/Tool/Attribute.cs b/Library.Core/NodeFlow/Tool/Attribute.cs
new file mode 100644
index 0000000..338d11b
--- /dev/null
+++ b/Library.Core/NodeFlow/Tool/Attribute.cs
@@ -0,0 +1,35 @@
+using Serein.Library.Api.Enums;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Serein.Library.Core.NodeFlow.Tool
+{
+ ///
+ /// 用来判断一个类是否需要注册并构建实例(单例模式场景使用)
+ ///
+ [AttributeUsage(AttributeTargets.Class)]
+ public class DynamicFlowAttribute(bool scan = true) : Attribute
+ {
+ public bool Scan { get; set; } = scan;
+ }
+
+ ///
+ /// 标记一个方法是什么类型,加载dll后用来拖拽到画布中
+ ///
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
+ public class MethodDetailAttribute(DynamicNodeType methodDynamicType,
+ string methodTips = "",
+ bool scan = true,
+ string lockName = "") : Attribute
+ {
+ public bool Scan { get; set; } = scan;
+ public string MethodTips { get; } = methodTips;
+ public DynamicNodeType MethodDynamicType { get; } = methodDynamicType;
+ public string LockName { get; } = lockName;
+ }
+
+
+}
diff --git a/Library.Core/NodeFlow/Tool/DynamicTool.cs b/Library.Core/NodeFlow/Tool/DynamicTool.cs
new file mode 100644
index 0000000..058eb11
--- /dev/null
+++ b/Library.Core/NodeFlow/Tool/DynamicTool.cs
@@ -0,0 +1,202 @@
+using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Drawing.Printing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Serein.Library.Core.NodeFlow.Tool
+{
+
+ #region 锁、tsk工具 (已注释)
+ /*public class LockManager
+ {
+ private readonly ConcurrentDictionary _locks = new ConcurrentDictionary();
+
+ public void CreateLock(string name)
+ {
+ _locks.TryAdd(name, new LockQueue());
+ }
+
+ public async Task AcquireLockAsync(string name, CancellationToken cancellationToken = default)
+ {
+ if (!_locks.ContainsKey(name))
+ {
+ throw new ArgumentException($"Lock with name '{name}' does not exist.");
+ }
+
+ var lockQueue = _locks[name];
+ var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
+
+ lock (lockQueue.Queue)
+ {
+ lockQueue.Queue.Enqueue(tcs);
+ if (lockQueue.Queue.Count == 1)
+ {
+ tcs.SetResult(true);
+ }
+ }
+
+ await tcs.Task.ConfigureAwait(false);
+
+ // 处理取消操作
+ if (cancellationToken.CanBeCanceled)
+ {
+ cancellationToken.Register(() =>
+ {
+ lock (lockQueue.Queue)
+ {
+ if (lockQueue.Queue.Contains(tcs))
+ {
+ tcs.TrySetCanceled();
+ }
+ }
+ });
+ }
+ }
+
+ public void ReleaseLock(string name)
+ {
+ if (!_locks.ContainsKey(name))
+ {
+ throw new ArgumentException($"Lock with name '{name}' does not exist.");
+ }
+
+ var lockQueue = _locks[name];
+
+ lock (lockQueue.Queue)
+ {
+ if (lockQueue.Queue.Count > 0)
+ {
+ lockQueue.Queue.Dequeue();
+
+ if (lockQueue.Queue.Count > 0)
+ {
+ var next = lockQueue.Queue.Peek();
+ next.SetResult(true);
+ }
+ }
+ }
+ }
+
+ private class LockQueue
+ {
+ public Queue> Queue { get; } = new Queue>();
+ }
+ }
+
+
+ public interface ITaskResult
+ {
+ object Result { get; }
+ }
+
+ public class TaskResult : ITaskResult
+ {
+ public TaskResult(T result)
+ {
+ Result = result;
+ }
+
+ public T Result { get; }
+
+ object ITaskResult.Result => Result;
+ }
+
+ public class DynamicTasks
+ {
+ private static readonly ConcurrentDictionary> TaskGuidPairs = new();
+ public static Task GetTask(string Guid)
+ {
+ TaskGuidPairs.TryGetValue(Guid, out Task task);
+ return task;
+ }
+
+ public static bool AddTask(string Guid, T result)
+ {
+ var task = Task.FromResult(new TaskResult(result));
+
+ return TaskGuidPairs.TryAdd(Guid, task);
+ }
+ }
+ public class TaskNodeManager
+ {
+ private readonly ConcurrentDictionary _taskQueues = new ConcurrentDictionary();
+
+ public void CreateTaskNode(string name)
+ {
+ _taskQueues.TryAdd(name, new TaskQueue());
+ }
+
+ public async Task WaitForTaskNodeAsync(string name, CancellationToken cancellationToken = default)
+ {
+ if (!_taskQueues.ContainsKey(name))
+ {
+ throw new ArgumentException($"Task node with name '{name}' does not exist.");
+ }
+
+ var taskQueue = _taskQueues[name];
+ var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
+
+ lock (taskQueue.Queue)
+ {
+ taskQueue.Queue.Enqueue(tcs);
+ if (taskQueue.Queue.Count == 1)
+ {
+ tcs.SetResult(true);
+ }
+ }
+
+ await tcs.Task.ConfigureAwait(false);
+
+ // 处理取消操作
+ if (cancellationToken.CanBeCanceled)
+ {
+ cancellationToken.Register(() =>
+ {
+ lock (taskQueue.Queue)
+ {
+ if (taskQueue.Queue.Contains(tcs))
+ {
+ tcs.TrySetCanceled();
+ }
+ }
+ });
+ }
+ }
+
+ public void CompleteTaskNode(string name)
+ {
+ if (!_taskQueues.ContainsKey(name))
+ {
+ throw new ArgumentException($"Task node with name '{name}' does not exist.");
+ }
+
+ var taskQueue = _taskQueues[name];
+
+ lock (taskQueue.Queue)
+ {
+ if (taskQueue.Queue.Count > 0)
+ {
+ taskQueue.Queue.Dequeue();
+
+ if (taskQueue.Queue.Count > 0)
+ {
+ var next = taskQueue.Queue.Peek();
+ next.SetResult(true);
+ }
+ }
+ }
+ }
+
+ private class TaskQueue
+ {
+ public Queue> Queue { get; } = new Queue>();
+ }
+ }*/
+ #endregion
+
+
+
+}
diff --git a/Library.Core/Serein.Library.Core.csproj b/Library.Core/Serein.Library.Core.csproj
new file mode 100644
index 0000000..232da48
--- /dev/null
+++ b/Library.Core/Serein.Library.Core.csproj
@@ -0,0 +1,52 @@
+
+
+
+ net8.0-windows7.0
+ enable
+ enable
+ D:\Project\C#\DynamicControl\SereinFlow\.Output
+ Library
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Library/SerinExpression/ConditionResolver.cs b/Library.Core/SerinExpression/ConditionResolver.cs
similarity index 99%
rename from Library/SerinExpression/ConditionResolver.cs
rename to Library.Core/SerinExpression/ConditionResolver.cs
index f95b47b..0e13911 100644
--- a/Library/SerinExpression/ConditionResolver.cs
+++ b/Library.Core/SerinExpression/ConditionResolver.cs
@@ -1,6 +1,6 @@
using System.Reflection;
-namespace Serein.Library.SerinExpression
+namespace Serein.LibraryCore.SerinExpression
{
///
/// 条件解析抽象类
diff --git a/Library/SerinExpression/SerinConditionParser.cs b/Library.Core/SerinExpression/SerinConditionParser.cs
similarity index 99%
rename from Library/SerinExpression/SerinConditionParser.cs
rename to Library.Core/SerinExpression/SerinConditionParser.cs
index 5b9348e..3a57418 100644
--- a/Library/SerinExpression/SerinConditionParser.cs
+++ b/Library.Core/SerinExpression/SerinConditionParser.cs
@@ -1,7 +1,7 @@
using System.Globalization;
using System.Reflection;
-namespace Serein.Library.SerinExpression;
+namespace Serein.LibraryCore.SerinExpression;
public class SerinConditionParser
{
@@ -290,6 +290,7 @@ public class SerinConditionParser
{
">" => ValueTypeConditionResolver.Operator.GreaterThan,
"<" => ValueTypeConditionResolver.Operator.LessThan,
+ "=" => ValueTypeConditionResolver.Operator.Equal,
"==" => ValueTypeConditionResolver.Operator.Equal,
">=" => ValueTypeConditionResolver.Operator.GreaterThanOrEqual,
"≥" => ValueTypeConditionResolver.Operator.GreaterThanOrEqual,
diff --git a/Library/SerinExpression/SerinExpressionEvaluator.cs b/Library.Core/SerinExpression/SerinExpressionEvaluator.cs
similarity index 92%
rename from Library/SerinExpression/SerinExpressionEvaluator.cs
rename to Library.Core/SerinExpression/SerinExpressionEvaluator.cs
index 97602c8..0a12633 100644
--- a/Library/SerinExpression/SerinExpressionEvaluator.cs
+++ b/Library.Core/SerinExpression/SerinExpressionEvaluator.cs
@@ -1,6 +1,6 @@
using System.Data;
-namespace Serein.Library.SerinExpression
+namespace Serein.LibraryCore.SerinExpression
{
public class SerinArithmeticExpressionEvaluator
{
@@ -25,7 +25,16 @@ namespace Serein.Library.SerinExpression
public class SerinExpressionEvaluator
{
- public static object Evaluate(string expression, object targetObJ, out bool IsChange)
+ ///
+ ///
+ ///
+ /// 表达式
+ /// 操作对象
+ /// 是否改变了对象(get语法)
+ ///
+ ///
+ ///
+ public static object Evaluate(string expression, object targetObJ, out bool isChange)
{
var parts = expression.Split([' '], 2);
if (parts.Length != 2)
@@ -45,7 +54,7 @@ namespace Serein.Library.SerinExpression
_ => throw new NotSupportedException($"Operation {operation} is not supported.")
};
- IsChange = operation switch
+ isChange = operation switch
{
"@num" => true,
"@call" => true,
diff --git a/Library/ServiceContainer.cs b/Library.Core/ServiceContainer.cs
similarity index 100%
rename from Library/ServiceContainer.cs
rename to Library.Core/ServiceContainer.cs
diff --git a/Library/Tool/DataHelper.cs b/Library.Core/Tool/DataHelper.cs
similarity index 100%
rename from Library/Tool/DataHelper.cs
rename to Library.Core/Tool/DataHelper.cs
diff --git a/Library.Framework/Http/Attribute.cs b/Library.Framework/Http/Attribute.cs
new file mode 100644
index 0000000..2971e2e
--- /dev/null
+++ b/Library.Framework/Http/Attribute.cs
@@ -0,0 +1,167 @@
+using Serein.Library.Framework.NodeFlow;
+using System;
+
+namespace Serein.Library.Framework.Http
+{
+
+ /////
+ ///// 用来判断一个类是否需要注册并构建实例(单例模式场景使用)
+ /////
+ //[AttributeUsage(AttributeTargets.Class)]
+ //public class DynamicFlowAttribute : Attribute
+ //{
+ // public DynamicFlowAttribute(bool scan = true)
+ // {
+ // Scan = scan;
+ // }
+ // public bool Scan { get; set; }
+ //}
+
+ /////
+ ///// 标记一个方法是什么类型,加载dll后用来拖拽到画布中
+ /////
+ //[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
+ //public class MethodDetailAttribute : Attribute
+ //{
+
+ // public MethodDetailAttribute(DynamicNodeType methodDynamicType,
+ // string methodTips = "",
+ // bool scan = true,
+ // string lockName = "")
+ // {
+ // Scan = scan;
+ // MethodDynamicType = methodDynamicType;
+ // MethodTips = methodTips;
+ // LockName = lockName;
+ // }
+ // public bool Scan { get; set; }
+ // public string MethodTips { get; }
+ // public DynamicNodeType MethodDynamicType { get; }
+ // public string LockName { get; }
+ //}
+
+ ///
+ /// 是否为显式参数
+ ///
+ //[AttributeUsage(AttributeTargets.Parameter)]
+ //public class ExplicitAttribute : Attribute // where TEnum : Enum
+ //{
+ //}
+
+
+
+ ///
+ /// 表示参数为url中的数据(Get请求中不需要显式标注)
+ ///
+ [AttributeUsage(AttributeTargets.Parameter)]
+ public sealed class IsUrlDataAttribute : Attribute
+ {
+
+ }
+
+ ///
+ /// 表示入参参数为整个boby的数据
+ ///
+ /// 例如:User类型含有int id、string name字段
+ ///
+ /// ① Add(User user)
+ /// 请求需要传入的json为
+ /// {"user":{
+ /// "id":2,
+ /// "name":"李志忠"}}
+ ///
+ /// ② Add([Boby]User user)
+ /// 请求需要传入的json为
+ /// {"id":2,"name":"李志忠"}
+ ///
+ ///
+ [AttributeUsage(AttributeTargets.Parameter)]
+ public sealed class IsBobyDataAttribute : Attribute
+ {
+
+ }
+
+ ///
+ /// 表示该控制器会被自动注册(与程序集同一命名空间,暂时不支持运行时自动加载DLL,需要手动注册)
+ ///
+ [AttributeUsage(AttributeTargets.Class)]
+ public sealed class AutoHostingAttribute : Attribute
+ {
+ public AutoHostingAttribute(string url = "")
+ {
+ Url = url;
+ }
+ public string Url { get; }
+ }
+ ///
+ /// 表示该属性为自动注入依赖项
+ ///
+ [AttributeUsage(AttributeTargets.Property)]
+ public sealed class AutoInjectionAttribute : Attribute
+ {
+ }
+
+
+ ///
+ /// 方法的接口类型与附加URL
+ ///
+ ///
+ /// 假设UserController.Add()的WebAPI特性中
+ /// http是HTTP.POST
+ /// url被显示标明“temp”
+ /// 那么请求的接口是POST,URL是
+ /// [http://localhost:8080]/user/add/temp
+ ///
+ ///
+ ///
+ [AttributeUsage(AttributeTargets.Method)]
+
+ public sealed class WebApiAttribute : Attribute
+
+ {
+ public API Type;
+ public string Url;
+ ///
+ /// 方法名称不作为url的部分
+ ///
+ public bool IsUrl;
+ }
+ [AttributeUsage(AttributeTargets.Method)]
+
+ public sealed class ApiPostAttribute : Attribute
+
+ {
+ public string Url;
+ ///
+ /// 方法名称不作为url的部分
+ ///
+ public bool IsUrl = true;
+ }
+ [AttributeUsage(AttributeTargets.Method)]
+
+ public sealed class ApiGetAttribute : Attribute
+
+ {
+ public string Url;
+ ///
+ /// 方法名称不作为url的部分
+ ///
+ public bool IsUrl = true;
+ }
+ /*public sealed class WebApiAttribute(API http, bool isUrl = true, string url = "") : Attribute
+ {
+ public API Http { get; } = http;
+ public string Url { get; } = url;
+ ///
+ /// 方法名称不作为url的部分
+ ///
+ public bool IsUrl { get; } = isUrl;
+ }*/
+ public enum API
+ {
+ POST,
+ GET,
+ //PUT,
+ //DELETE
+ }
+}
diff --git a/Library.Framework/Http/ControllerBase.cs b/Library.Framework/Http/ControllerBase.cs
new file mode 100644
index 0000000..7eba7a1
--- /dev/null
+++ b/Library.Framework/Http/ControllerBase.cs
@@ -0,0 +1,19 @@
+using System;
+
+namespace Serein.Library.Framework.Http
+{
+ public class ControllerBase
+ {
+
+ public string Url { get; set; }
+
+ public string BobyData { get; set; }
+
+ public string GetLog(Exception ex)
+ {
+ return "Url : " + Url + Environment.NewLine +
+ "Ex : " + ex.Message + Environment.NewLine +
+ "Data : " + BobyData + Environment.NewLine;
+ }
+ }
+}
diff --git a/Library.Framework/Http/Router.cs b/Library.Framework/Http/Router.cs
new file mode 100644
index 0000000..6e6ba99
--- /dev/null
+++ b/Library.Framework/Http/Router.cs
@@ -0,0 +1,761 @@
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Serein.Library.Api.Api;
+using Serein.Library.Framework.IOC;
+using Serein.Tool;
+using System;
+using System.Collections;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Reflection;
+using System.Runtime.Remoting.Messaging;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web;
+using Enum = System.Enum;
+using Type = System.Type;
+
+namespace Serein.Library.Framework.Http
+{
+
+
+
+ ///
+ /// 路由注册与解析
+ ///
+ public class Router
+ {
+
+ private readonly ConcurrentDictionary _controllerAutoHosting; // 存储是否实例化
+ private readonly ConcurrentDictionary _controllerTypes; // 存储控制器类型
+ private readonly ConcurrentDictionary _controllerInstances; // 存储控制器实例对象
+ private readonly ConcurrentDictionary> _routes; // 用于存储路由信息
+
+ private readonly ISereinIoc serviceRegistry; // 用于存储路由信息
+
+ //private Type PostRequest;
+
+ public Router(ISereinIoc serviceRegistry) // 构造函数,初始化 Router 类的新实例
+ {
+ this.serviceRegistry = serviceRegistry;
+
+ _routes = new ConcurrentDictionary>(); // 初始化路由字典
+
+ _controllerAutoHosting = new ConcurrentDictionary(); // 初始化控制器实例对象字典
+ _controllerTypes = new ConcurrentDictionary(); // 初始化控制器实例对象字典
+ _controllerInstances = new ConcurrentDictionary(); // 初始化控制器实例对象字典
+
+ foreach (API method in Enum.GetValues(typeof(API))) // 遍历 HTTP 枚举类型的所有值
+ {
+ _routes.TryAdd(method.ToString(), new ConcurrentDictionary()); // 初始化每种 HTTP 方法对应的路由字典
+ }
+
+ // 获取当前程序集
+ Assembly assembly = Assembly.GetExecutingAssembly();
+
+ // 获取包含“Controller”名称的类型
+ var controllerTypes = assembly.GetTypes()
+ .Where(t => t.Name.Contains("Controller"));
+
+ Type baseAttribute = typeof(AutoHostingAttribute);
+ Type baseController = typeof(ControllerBase);
+ foreach (var controllerType in controllerTypes)
+ {
+ if (controllerType.IsSubclassOf(baseController) && controllerType.IsDefined(baseAttribute))
+ {
+
+ // 如果属于控制器,并标记了AutoHosting特性,进行自动注册
+ AutoRegisterAutoController(controllerType);
+ }
+ else
+ {
+ continue;
+ }
+ }
+ }
+
+
+ ///
+ /// 自动注册 自动实例化控制器 类型
+ ///
+ ///
+ public void AutoRegisterAutoController(Type controllerType) // 方法声明,用于注册并实例化控制器类型
+ {
+ if (!controllerType.IsClass || controllerType.IsAbstract) return; // 如果不是类或者是抽象类,则直接返回
+
+ var autoHostingAttribute = controllerType.GetCustomAttribute();
+ if (autoHostingAttribute != null) {
+ foreach (var method in controllerType.GetMethods()) // 遍历控制器类型的所有方法
+ {
+ var apiGetAttribute = method.GetCustomAttribute();
+ var apiPostAttribute = method.GetCustomAttribute();
+ if( apiGetAttribute == null && apiPostAttribute == null )
+ {
+ continue;
+ }
+
+
+
+ WebApiAttribute webApiAttribute = new WebApiAttribute()
+ {
+ Type = apiGetAttribute != null ? API.GET : API.POST,
+ Url = apiGetAttribute != null ? apiGetAttribute.Url : apiPostAttribute.Url,
+ IsUrl = apiGetAttribute != null ? apiGetAttribute.IsUrl : apiPostAttribute.IsUrl,
+ };
+
+
+
+ if (apiPostAttribute != null) // 如果存在 WebAPIAttribute 属性
+ {
+ var url = AddRoutesUrl(autoHostingAttribute,
+ webApiAttribute,
+ controllerType, method);
+ Console.WriteLine(url);
+ if (url == null) continue;
+ _controllerAutoHosting[url] = true;
+ _controllerTypes[url] = controllerType;
+
+ _controllerInstances[url] = null;
+
+ }
+
+
+ /* var routeAttribute = method.GetCustomAttribute(); // 获取方法上的 WebAPIAttribute 自定义属性
+ if (routeAttribute != null) // 如果存在 WebAPIAttribute 属性
+ {
+ var url = AddRoutesUrl(autoHostingAttribute, routeAttribute, controllerType, method);
+ Console.WriteLine(url);
+ if (url == null) continue;
+ _controllerAutoHosting[url] = true;
+ _controllerTypes[url] = controllerType;
+ _controllerInstances[url] = null;
+ }*/
+ }
+ }
+ }
+ ///
+ /// 手动注册 自动实例化控制器实例
+ ///
+ public void RegisterAutoController() // 方法声明,用于动态注册路由
+ {
+ Type controllerType = typeof(T); // 获取控制器实例的类型
+ foreach (var method in controllerType.GetMethods()) // 遍历控制器类型的所有方法
+ {
+ var apiGetAttribute = method.GetCustomAttribute();
+ var apiPostAttribute = method.GetCustomAttribute();
+ if (apiGetAttribute == null && apiPostAttribute == null)
+ {
+ continue;
+ }
+
+
+
+ WebApiAttribute webApiAttribute = new WebApiAttribute()
+ {
+ Type = apiGetAttribute != null ? API.GET : API.POST,
+ Url = apiGetAttribute != null ? apiGetAttribute.Url : apiPostAttribute.Url,
+ IsUrl = apiGetAttribute != null ? apiGetAttribute.IsUrl : apiPostAttribute.IsUrl,
+ };
+
+
+
+ var url = AddRoutesUrl(null, webApiAttribute, controllerType, method);
+
+ if (url == null) continue;
+ _controllerAutoHosting[url] = true;
+ _controllerTypes[url] = controllerType;
+
+ _controllerInstances[url] = null;
+
+ }
+ }
+
+
+ ///
+ /// 手动注册 实例持久控制器实例
+ ///
+ ///
+ public void RegisterController(TController controllerInstance) where TController : ControllerBase // 方法声明,用于动态注册路由
+ {
+ if(controllerInstance == null) return;
+ Type controllerType = controllerInstance.GetType(); // 获取控制器实例的类型
+ foreach (var method in controllerType.GetMethods()) // 遍历控制器类型的所有方法
+ {
+ var apiGetAttribute = method.GetCustomAttribute();
+ var apiPostAttribute = method.GetCustomAttribute();
+ if (apiGetAttribute == null && apiPostAttribute == null)
+ {
+ continue;
+ }
+
+
+
+ WebApiAttribute webApiAttribute = new WebApiAttribute()
+ {
+ Type = apiGetAttribute != null ? API.GET : API.POST,
+ Url = apiGetAttribute != null ? apiGetAttribute.Url : apiPostAttribute.Url,
+ IsUrl = apiGetAttribute != null ? apiGetAttribute.IsUrl : apiPostAttribute.IsUrl,
+ };
+
+
+
+ var url = AddRoutesUrl(null, webApiAttribute, controllerType, method);
+
+ if (url == null) continue;
+ _controllerInstances[url] = controllerInstance;
+ _controllerAutoHosting[url] = false;
+ }
+ }
+
+ ///
+ /// 从方法中收集路由信息
+ ///
+ ///
+ public string AddRoutesUrl(AutoHostingAttribute autoHostingAttribute, WebApiAttribute webAttribute, Type controllerType, MethodInfo method)
+ {
+ string controllerName;
+ if (autoHostingAttribute == null || string.IsNullOrWhiteSpace(autoHostingAttribute.Url))
+ {
+ controllerName = controllerType.Name.Replace("Controller", "").ToLower(); // 获取控制器名称并转换为小写
+ }
+ else
+ {
+ controllerName = autoHostingAttribute.Url;
+ }
+
+ var httpMethod = webAttribute.Type; // 获取 HTTP 方法
+ var customUrl = webAttribute.Url; // 获取自定义 URL
+
+ string url;
+
+ if (webAttribute.IsUrl)
+ {
+
+ if (string.IsNullOrEmpty(customUrl)) // 如果自定义 URL 为空
+ {
+ url = $"/{controllerName}/{method.Name}".ToLower(); // 构建默认 URL
+ }
+ else
+ {
+ customUrl = CleanUrl(customUrl);
+ url = $"/{controllerName}/{method.Name}/{customUrl}".ToLower();// 清理自定义 URL,并构建新的 URL
+ }
+ _routes[httpMethod.ToString()].TryAdd(url, method); // 将 URL 和方法添加到对应的路由字典中
+ }
+ else
+ {
+ if (string.IsNullOrEmpty(customUrl)) // 如果自定义 URL 为空
+ {
+ url = $"/{controllerName}".ToLower(); // 构建默认 URL
+ }
+ else
+ {
+ customUrl = CleanUrl(customUrl);
+ url = $"/{controllerName}/{customUrl}".ToLower();// 清理自定义 URL,并构建新的 URL
+ }
+ _routes[httpMethod.ToString()].TryAdd(url, method); // 将 URL 和方法添加到对应的路由字典中
+ }
+
+ return url;
+
+ }
+
+
+ ///
+ /// 收集路由信息
+ ///
+ ///
+ public void CollectRoutes(Type controllerType)
+ {
+ string controllerName = controllerType.Name.Replace("Controller", "").ToLower(); // 获取控制器名称并转换为小写
+ foreach (var method in controllerType.GetMethods()) // 遍历控制器类型的所有方法
+ {
+ var routeAttribute = method.GetCustomAttribute(); // 获取方法上的 WebAPIAttribute 自定义属性
+ if (routeAttribute != null) // 如果存在 WebAPIAttribute 属性
+ {
+ var customUrl = routeAttribute.Url; // 获取自定义 URL
+ string url;
+ if (string.IsNullOrEmpty(customUrl)) // 如果自定义 URL 为空
+ {
+ url = $"/api/{controllerName}/{method.Name}".ToLower(); // 构建默认 URL
+ }
+ else
+ {
+ customUrl = CleanUrl(customUrl);
+ url = $"/api/{controllerName}/{method.Name}/{customUrl}".ToLower();// 清理自定义 URL,并构建新的 URL
+ }
+ var httpMethod = routeAttribute.Type; // 获取 HTTP 方法
+ _routes[httpMethod.ToString()].TryAdd(url, method); // 将 URL 和方法添加到对应的路由字典中
+ }
+ }
+ }
+
+
+ ///
+ /// 解析路由,调用对应的方法
+ ///
+ ///
+ ///
+ public async Task RouteAsync(HttpListenerContext context)
+ {
+ var request = context.Request; // 获取请求对象
+ var response = context.Response; // 获取响应对象
+ var url = request.Url; // 获取请求的 URL
+ var httpMethod = request.HttpMethod; // 获取请求的 HTTP 方法
+
+ var template = request.Url.AbsolutePath.ToLower();
+
+
+ if (!_routes[httpMethod].TryGetValue(template, out MethodInfo method))
+ {
+ return false;
+ }
+
+
+
+ var routeValues = GetUrlData(url); // 解析 URL 获取路由参数
+
+ ControllerBase controllerInstance;
+ if (!_controllerAutoHosting[template])
+ {
+ controllerInstance = (ControllerBase)_controllerInstances[template];
+ }
+ else
+ {
+
+ controllerInstance = (ControllerBase)serviceRegistry.Instantiate(_controllerTypes[template]);// 使用反射创建控制器实例
+
+
+ }
+
+ if (controllerInstance == null)
+ {
+ return false; // 未找到控制器实例
+ }
+
+ controllerInstance.Url = url.AbsolutePath;
+ object result;
+ switch (httpMethod) // 根据请求的 HTTP 方法执行不同的操作
+ {
+ case "GET": // 如果是 GET 请求,传入方法、控制器、url参数
+ result = InvokeControllerMethodWithRouteValues(method, controllerInstance, routeValues);
+ break;
+ case "POST": // POST 请求传入方法、控制器、请求体内容,url参数
+ var requestBody = await ReadRequestBodyAsync(request); // 读取请求体内容
+ controllerInstance.BobyData = requestBody;
+ var requestJObject = requestBody.FromJSON