mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-01 14:06:36 +08:00
忘记改啥了*1
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Reflection;
|
||||
using System.Reflection.Emit;
|
||||
using System.Text;
|
||||
@@ -56,43 +57,37 @@ namespace Serein.Library.Utils
|
||||
/// <param name="methodInfo"></param>
|
||||
/// <param name="delegate"></param>
|
||||
/// <returns></returns>
|
||||
public static EmitMethodType CreateDynamicMethod( MethodInfo methodInfo,out Delegate @delegate)
|
||||
public static EmitMethodType CreateDynamicMethod(MethodInfo methodInfo,out Delegate @delegate)
|
||||
{
|
||||
bool IsTask = IsGenericTask(methodInfo.ReturnType, out var taskGenericsType);
|
||||
bool IsTaskGenerics = taskGenericsType != null;
|
||||
DynamicMethod dynamicMethod;
|
||||
if (IsTask)
|
||||
{
|
||||
if (IsTaskGenerics)
|
||||
{
|
||||
|
||||
dynamicMethod = new DynamicMethod(
|
||||
name: methodInfo.Name + "_DynamicMethod",
|
||||
returnType: typeof(Task<object>),
|
||||
parameterTypes: new[] { typeof(object), typeof(object[]) },
|
||||
restrictedSkipVisibility: true // 跳过私有方法访问限制
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
dynamicMethod = new DynamicMethod(
|
||||
name: methodInfo.Name + "_DynamicMethod",
|
||||
returnType: typeof(Task),
|
||||
parameterTypes: new[] { typeof(object), typeof(object[]) },
|
||||
restrictedSkipVisibility: true // 跳过私有方法访问限制
|
||||
);
|
||||
}
|
||||
Type returnType;
|
||||
if (!IsTask)
|
||||
{
|
||||
// 普通方法
|
||||
returnType = typeof(object);
|
||||
}
|
||||
else
|
||||
{
|
||||
dynamicMethod = new DynamicMethod(
|
||||
name: methodInfo.Name + "_DynamicMethod",
|
||||
returnType: typeof(object),
|
||||
parameterTypes: new[] { typeof(object), typeof(object[]) },
|
||||
restrictedSkipVisibility: true // 跳过私有方法访问限制
|
||||
);
|
||||
// 异步方法
|
||||
if (IsTaskGenerics)
|
||||
{
|
||||
returnType = typeof(Task<object>);
|
||||
}
|
||||
else
|
||||
{
|
||||
returnType = typeof(Task);
|
||||
}
|
||||
}
|
||||
|
||||
dynamicMethod = new DynamicMethod(
|
||||
name: methodInfo.Name + "_DynamicEmitMethod",
|
||||
returnType: returnType,
|
||||
parameterTypes: new[] { typeof(object), typeof(object[]) }, // 方法实例、方法入参
|
||||
restrictedSkipVisibility: true // 跳过私有方法访问限制
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
13
Library/Utils/NativeDllHelper.cs
Normal file
13
Library/Utils/NativeDllHelper.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Serein.Library.Utils
|
||||
{
|
||||
|
||||
}
|
||||
@@ -51,6 +51,10 @@ namespace Serein.Library.Utils.SereinExpression
|
||||
/// <exception cref="NotSupportedException"></exception>
|
||||
public static object Evaluate(string expression, object targetObJ, out bool isChange)
|
||||
{
|
||||
if(expression is null || targetObJ is null)
|
||||
{
|
||||
throw new Exception("表达式条件expression is null、 targetObJ is null");
|
||||
}
|
||||
var parts = expression.Split(new[] { ' ' }, 2, StringSplitOptions.None);
|
||||
if (parts.Length != 2)
|
||||
{
|
||||
@@ -60,6 +64,7 @@ namespace Serein.Library.Utils.SereinExpression
|
||||
var operation = parts[0].ToLower();
|
||||
var operand = parts[1][0] == '.' ? parts[1].Substring(1) : parts[1];
|
||||
object result;
|
||||
isChange = false;
|
||||
if (operation == "@num")
|
||||
{
|
||||
result = ComputedNumber(targetObJ, operand);
|
||||
@@ -70,10 +75,12 @@ namespace Serein.Library.Utils.SereinExpression
|
||||
}
|
||||
else if (operation == "@get")
|
||||
{
|
||||
isChange = true;
|
||||
result = GetMember(targetObJ, operand);
|
||||
}
|
||||
else if (operation == "@set")
|
||||
{
|
||||
isChange = true;
|
||||
result = SetMember(targetObJ, operand);
|
||||
}
|
||||
else
|
||||
@@ -81,14 +88,7 @@ namespace Serein.Library.Utils.SereinExpression
|
||||
throw new NotSupportedException($"Operation {operation} is not supported.");
|
||||
}
|
||||
|
||||
if(operation == "@set")
|
||||
{
|
||||
isChange = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isChange = false;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user