优化了脚本生成AST时的代码提示,增加了脚本运行时错误提示。

This commit is contained in:
fengjiayi
2025-07-09 21:49:26 +08:00
parent 4da8bf6b84
commit 70f674ca1b
32 changed files with 1218 additions and 266 deletions

View File

@@ -16,6 +16,20 @@ namespace Serein.Library.Utils
// 类型缓存,键为类型的唯一名称(可以根据实际需求调整生成方式)
static Dictionary<string, Type> typeCache = new Dictionary<string, Type>();
/// <summary>
/// 获取运行时创建过的类型
/// </summary>
/// <param name="className"></param>
/// <returns></returns>
public static Type GetCacheType(string className)
{
if(typeCache.TryGetValue(className, out var type))
{
return type;
}
return null;
}
public static object Resolve(IDictionary<string, object> properties, string typeName)
{
var obj = CreateObjectWithProperties(properties, typeName);

View File

@@ -101,8 +101,6 @@ namespace Serein.Library
#endregion
/// <summary>
/// 设置运行流程
/// </summary>
@@ -138,8 +136,35 @@ namespace Serein.Library
}
/// <summary>
/// 尝试在UI线程上触发事件
/// </summary>
/// <param name="action"></param>
/// <returns></returns>
public async static Task TriggerEvent(Action action)
{
if (environment is null)
{
action?.Invoke();
}
else
{
var uco = environment.UIContextOperation;
if (uco is null)
{
action?.Invoke();
}
else
{
await uco.InvokeAsync(() =>
{
action?.Invoke();
});
}
}
}
}