mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
2. Script项目脚本修复了 RawString 原始字符串存在的问题 3. Script使用了ValueNode统一了值类型节点,为后续扩展更多的值类型做准备 4. TypeHelper.ToTypeOfString()方法中添加了部分值类型的"Type[]”与“List<Type>”的显式定义,用于脚本在类型中定义数组成员 5. Script项目脚本默认挂载的json方法拆分为jsonObj(String)与jsonStr(Object)以支持序列化与反序列化 6. 项目保存为dnf项目文件时,将不再保存名称为”Default"并且没有节点的画布,避免重复保存时默认画布增多。
64 lines
2.0 KiB
C#
64 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Serein.Script.Node
|
|
{
|
|
/// <summary>
|
|
/// 字符串字面量节点
|
|
/// </summary>
|
|
public class StringNode : ValueNode<string>
|
|
{
|
|
public StringNode(string input) : base()
|
|
{
|
|
// 使用 StringBuilder 来构建输出
|
|
StringBuilder output = new StringBuilder(input.Length);
|
|
|
|
for (int i = 0; i < input.Length; i++)
|
|
{
|
|
if (i < input.Length - 1 && input[i] == '\\') // 找到反斜杠
|
|
{
|
|
char nextChar = input[i + 1];
|
|
|
|
// 处理转义符
|
|
switch (nextChar)
|
|
{
|
|
case 'r':
|
|
output.Append('\r');
|
|
i++; // 跳过 'r'
|
|
break;
|
|
case 'n':
|
|
output.Append('\n');
|
|
i++; // 跳过 'n'
|
|
break;
|
|
case 't':
|
|
output.Append('\t');
|
|
i++; // 跳过 't'
|
|
break;
|
|
case '\\': // 字面量反斜杠
|
|
output.Append('\\');
|
|
i++; // 跳过第二个 '\\'
|
|
break;
|
|
case '"': // 字符串反斜杠
|
|
output.Append('"');
|
|
i++; // 跳过第二个 '"'
|
|
break;
|
|
default:
|
|
output.Append(input[i]); // 不是转义符,保留反斜杠
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
output.Append(input[i]); // 其他字符直接添加
|
|
}
|
|
}
|
|
Value = output.ToString();
|
|
}
|
|
}
|
|
|
|
|
|
}
|