XFEExtension
【DLL】XFE各类拓展是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等
关注
0
Fork
0
Star
0
返回提交历史
Modified
XFEExtension.NetCore.Test/Program.cs
+4
-4
Modified
XFEExtension.NetCore/XFEExtension.NetCore.csproj
+3
-3
Modified
XFEExtension.NetCore/XFETransform/JsonConverter/JsonNodeConverter.cs
+11
-4
XFEstudio/XFEExtension
更新引用并优化 JSON 解析逻辑
在 `Program.cs` 中移除对 `XFEPackage` 的引用,添加对 `XFEExtension` 和 `XFETransform.JsonConverter` 的引用,修改主函数以读取 JSON 文件内容。 在 `XFEExtension.NetCore.csproj` 中将版本号更新至 `3.3.2`。 在 `JsonNodeConverter.cs` 中优化了代码逻辑,添加了对 `currentPosition` 列表长度的检查,修改了 `currentLayer` 的处理逻辑,并细化了不同状态下的 JSON 解析处理。
eee7174
代码差异
3 个文件
+18
-11
@@ -1,10 +1,10 @@
1
using XFEExtension.NetCore.FileExtension.XFEPackage;
1
using XFEExtension.NetCore.FileExtension;
2
using XFEExtension.NetCore.XFETransform.JsonConverter;
2
3
3
4
internal class Program
4
5
{
5
6
private static void Main(string[] args)
6
7
{
7
XFEPackage.PackFile(@"C:\Users\XFEstudio\AppData\LocalLow\Element Games\Reality Break", "测试.package");
8
XFEPackage.UnPackFile("测试.package", "测试");
8
QueryableJsonNode jsonNode = @"C:\Users\XFEstudio\Desktop\测试\Json失败示例.txt".ReadOut()!;
9
9
}
10
}
10
}
@@ -5,7 +5,7 @@
5
5
<ImplicitUsings>enable</ImplicitUsings>
6
6
<Nullable>enable</Nullable>
7
7
<GenerateDocumentationFile>True</GenerateDocumentationFile>
8
<Version>3.3.1</Version>
8
<Version>3.3.2</Version>
9
9
<Title>XFEExtension</Title>
10
10
<RepositoryUrl>https://github.com/XFEstudio/XFEExtension</RepositoryUrl>
11
11
<AnalysisLevel>latest</AnalysisLevel>
@@ -21,9 +21,9 @@
21
21
<PackageReleaseNotes>
22
22
## 调整
23
23
24
简化输入缓冲区处理并更新版本号
24
更新引用并优化 JSON 解析逻辑
25
25
26
在 `BufferExtension.cs` 文件中,移除了对输入缓冲区为空或长度为零的异常抛出,改为返回一个空数组,以简化错误处理逻辑。
26
在 `Program.cs` 中移除对 `XFEPackage` 的引用,添加对 `XFEExtension` 和 `XFETransform.JsonConverter` 的引用,修改主函数以读取 JSON 文件内容。
27
27
28
28
## 新增
29
29
@@ -78,8 +78,11 @@ public class JsonNodeConverter(string jsonString)
78
78
else
79
79
Console.WriteLine($"设置复杂Json节点失败:{currentLayer}\t{currentPropertyName}\t{currentPropertyValue}");
80
80
}
81
currentPosition.RemoveAt(currentPosition.Count - 1);
82
currentLayer--;
81
if (currentPosition.Count > 0)
82
{
83
currentPosition.RemoveAt(currentPosition.Count - 1);
84
currentLayer--;
85
}
83
86
currentPropertyName = "";
84
87
currentPropertyValue = "";
85
88
}
@@ -151,7 +154,8 @@ public class JsonNodeConverter(string jsonString)
151
154
if ((currentState != CurrentState.Property && currentState != CurrentState.StringPropertyValue) || currentState == CurrentState.AfterPropertyValue || currentState == CurrentState.AfterProperty)
152
155
{
153
156
currentSymbol = JsonSymbol.Comma;
154
currentPosition[currentLayer + 1] += 1;
157
if (currentLayer >= -1)
158
currentPosition[currentLayer + 1] += 1;
155
159
if (currentState != CurrentState.ListValue)
156
160
currentState = CurrentState.BeforeProperty;
157
161
if (lastSymbol == JsonSymbol.Text || lastSymbol == JsonSymbol.DoubleQuotationMark)
@@ -201,23 +205,26 @@ public class JsonNodeConverter(string jsonString)
201
205
currentState = CurrentState.None;
202
206
break;
203
207
default:
204
currentSymbol = JsonSymbol.Text;
205
208
switch (currentState)
206
209
{
207
210
case CurrentState.Property:
208
211
currentPropertyName += current;
212
currentSymbol = JsonSymbol.Text;
209
213
break;
210
214
case CurrentState.PropertyValue or CurrentState.StringPropertyValue:
211
215
currentPropertyValue += current;
216
currentSymbol = JsonSymbol.Text;
212
217
break;
213
218
case CurrentState.ListValue:
214
219
currentPropertyValue += current;
220
currentSymbol = JsonSymbol.Text;
215
221
break;
216
222
case CurrentState.BeforePropertyValue:
217
223
if (IsNormalValueExceptString(current))
218
224
{
219
225
currentPropertyValue += current;
220
226
currentState = CurrentState.PropertyValue;
227
currentSymbol = JsonSymbol.Text;
221
228
}
222
229
break;
223
230
case CurrentState.None: