尝试使用源生成器规范NodeModel代码逻辑

This commit is contained in:
fengjiayi
2024-10-20 12:10:57 +08:00
parent 9931fa7436
commit e38833a58c
127 changed files with 5173 additions and 1839 deletions

View File

@@ -1,13 +1,8 @@
using Serein.Library.Api;
using Serein.Library.Attributes;
using Serein.Library.Core.NodeFlow;
using Serein.Library.Entity;
using Serein.Library.Utils;
using System;
using Serein.Library;
using System.Collections.Concurrent;
using System.ComponentModel;
using System.Reflection;
using System.Text.RegularExpressions;
namespace Serein.NodeFlow.Tool;
@@ -77,7 +72,7 @@ public static class NodeMethodDetailsHelper
Type? returnType;
bool isTask = IsGenericTask(method.ReturnType, out var taskResult);
if (attribute.MethodDynamicType == Library.Enums.NodeType.Flipflop)
if (attribute.MethodDynamicType == Library.NodeType.Flipflop)
{
if (method.ReturnType.IsGenericType && method.ReturnType.GetGenericTypeDefinition() == typeof(Task<>))
{
@@ -126,7 +121,7 @@ public static class NodeMethodDetailsHelper
var md = new MethodDetails
var md = new MethodDetails() // 从DLL生成方法描述
{
ActingInstanceType = type,
// ActingInstance = instance,
@@ -137,7 +132,7 @@ public static class NodeMethodDetailsHelper
ParameterDetailss = explicitDataOfParameters,
ReturnType = returnType,
};
var dd = new DelegateDetails( emitMethodType, methodDelegate) ;
var dd = new DelegateDetails(emitMethodType, methodDelegate) ;
return (md, dd);
}
@@ -270,6 +265,7 @@ public static class NodeMethodDetailsHelper
/// <returns></returns>
private static string GetExplicitTypeName(Type type)
{
return type switch
{
Type t when t.IsEnum => "Select",