移除Json库
This commit is contained in:
parent
c3b7b0afd7
commit
b7eebd24e3
@ -6,7 +6,7 @@ WPF/.NET 8 上位机软件,通过自由配置硬件、全局变量、界面和
|
||||
|
||||
## Project
|
||||
|
||||
- **技术栈**: .NET 8 (net8.0-windows), WPF, Prism.DryIoc, OpenCvSharp4, EF Core SQLite, Newtonsoft.Json, Natasha (动态编译)
|
||||
- **技术栈**: .NET 8 (net8.0-windows), WPF, Prism.DryIoc, OpenCvSharp4, EF Core SQLite, System.Text.Json, Natasha (动态编译)
|
||||
- **入口点**: `PLCSharpWpf/App.xaml.cs` — Prism `Application` 子类,负责 DI 注册、导航配置、全局异常捕获
|
||||
- **Shell**: `PLCSharpWpf/VVMs/MainWindow/MainWindow.xaml` — 主窗口,包含侧导航 + 内容区
|
||||
- **语言**: C# (可空引用类型 `#nullable enable`), XAML
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using DryIoc;
|
||||
using Newtonsoft.Json;
|
||||
using PLCSharp.Core.Prism;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using PLCSharp.Models;
|
||||
using PLCSharp.VVMs.Authority;
|
||||
using PLCSharp.VVMs.MainWindow;
|
||||
@ -194,20 +195,23 @@ namespace PLCSharp
|
||||
if (File.Exists("./Config/EnvironmentVariable.json"))
|
||||
{
|
||||
var json = File.ReadAllText("./Config/EnvironmentVariable.json");
|
||||
dynamic config = JsonConvert.DeserializeObject(json);
|
||||
var config = JsonNode.Parse(json);
|
||||
try
|
||||
{
|
||||
foreach (var item in config.EnvironmentVariables)
|
||||
if (config?["EnvironmentVariables"] is JsonArray envVars)
|
||||
{
|
||||
string name = item.Name;
|
||||
string value = item.Value;
|
||||
Environment.SetEnvironmentVariable(name, value);
|
||||
foreach (var item in envVars)
|
||||
{
|
||||
string? name = item?["Name"]?.GetValue<string>();
|
||||
string? value = item?["Value"]?.GetValue<string>();
|
||||
if (name != null)
|
||||
Environment.SetEnvironmentVariable(name, value ?? "");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
28
PLCSharpWpf/Core/Tools/JsonOptions.cs
Normal file
28
PLCSharpWpf/Core/Tools/JsonOptions.cs
Normal file
@ -0,0 +1,28 @@
|
||||
#nullable enable
|
||||
using System.Text.Json;
|
||||
|
||||
namespace PLCSharp.Core.Tools
|
||||
{
|
||||
/// <summary>
|
||||
/// 全局共享的 System.Text.Json 序列化选项。
|
||||
/// </summary>
|
||||
public static class JsonOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 默认选项:属性名大小写不敏感(用于 EF Core 列序列化 / 反序列化)。
|
||||
/// </summary>
|
||||
public static JsonSerializerOptions Default { get; } = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 缩进输出选项(用于配置文件读写)。
|
||||
/// </summary>
|
||||
public static JsonSerializerOptions Indented { get; } = new()
|
||||
{
|
||||
PropertyNameCaseInsensitive = true,
|
||||
WriteIndented = true,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -20,7 +20,6 @@
|
||||
<PackageReference Include="DotNetCore.Natasha.CSharp.Compiler.Domain" Version="10.0.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.17" />
|
||||
<PackageReference Include="MiniExcel" Version="1.45.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
|
||||
<PackageReference Include="OpenCvSharp5.Windows" Version="5.0.0.20260718" />
|
||||
<PackageReference Include="Prism.DryIoc" Version="9.0.537" />
|
||||
<PackageReference Include="RoslynPad.Editor.Windows" Version="5.0.0" />
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using PLCSharp.Core.Tools;
|
||||
using PLCSharp.VVMs.Connects.ModbusTcp;
|
||||
using PLCSharp.VVMs.Connects.Socket;
|
||||
using Prism.Mvvm;
|
||||
@ -194,8 +196,8 @@ namespace PLCSharp.VVMs.Connects
|
||||
[Column("Params")]
|
||||
public string SerializedParams
|
||||
{
|
||||
get => JsonConvert.SerializeObject(Params); // 自动序列化
|
||||
set => Params = JsonConvert.DeserializeObject<ConnectParams>(value); // 自动反序列化
|
||||
get => JsonSerializer.Serialize(Params, JsonOptions.Default); // 自动序列化
|
||||
set => Params = JsonSerializer.Deserialize<ConnectParams>(value, JsonOptions.Default); // 自动反序列化
|
||||
|
||||
}
|
||||
|
||||
@ -215,8 +217,8 @@ namespace PLCSharp.VVMs.Connects
|
||||
[Column("DataItems")]
|
||||
public string SerializedDataItems
|
||||
{
|
||||
get => JsonConvert.SerializeObject(DataItems); // 自动序列化
|
||||
set => DataItems = value != null ? JsonConvert.DeserializeObject<ObservableCollection<DataItem>>(value) : []; // 自动反序列化
|
||||
get => JsonSerializer.Serialize(DataItems, JsonOptions.Default); // 自动序列化
|
||||
set => DataItems = value != null ? JsonSerializer.Deserialize<ObservableCollection<DataItem>>(value, JsonOptions.Default) : []; // 自动反序列化
|
||||
|
||||
}
|
||||
|
||||
@ -279,8 +281,8 @@ namespace PLCSharp.VVMs.Connects
|
||||
[Column("Clients")]
|
||||
public string SerializedClients
|
||||
{
|
||||
get => JsonConvert.SerializeObject(Clients); // 自动序列化
|
||||
set => Clients = JsonConvert.DeserializeObject<ObservableCollection<Connect>>(value); // 自动反序列化
|
||||
get => JsonSerializer.Serialize(Clients, JsonOptions.Default); // 自动序列化
|
||||
set => Clients = JsonSerializer.Deserialize<ObservableCollection<Connect>>(value, JsonOptions.Default); // 自动反序列化
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Prism.Mvvm;
|
||||
|
||||
namespace PLCSharp.VVMs.Connects.ModbusTcp
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using OpenCvSharp;
|
||||
using OpenCvSharp.WpfExtensions;
|
||||
using PLCSharp.Core.Common;
|
||||
@ -136,8 +137,8 @@ namespace PLCSharp.VVMs.Homepage
|
||||
|
||||
public string SerializedParams
|
||||
{
|
||||
get => JsonConvert.SerializeObject(Params); // 自动序列化
|
||||
set => Params = JsonConvert.DeserializeObject<ControlParams>(value); // 自动反序列化
|
||||
get => JsonSerializer.Serialize(Params, JsonOptions.Default); // 自动序列化
|
||||
set => Params = JsonSerializer.Deserialize<ControlParams>(value, JsonOptions.Default); // 自动反序列化
|
||||
|
||||
}
|
||||
private ControlParams _Params;
|
||||
@ -180,8 +181,8 @@ namespace PLCSharp.VVMs.Homepage
|
||||
|
||||
public string SerializedRangeValues
|
||||
{
|
||||
get => JsonConvert.SerializeObject(RangeValues); // 自动序列化
|
||||
set => RangeValues = JsonConvert.DeserializeObject<ObservableCollection<RangeValue>>(value); // 自动反序列化
|
||||
get => JsonSerializer.Serialize(RangeValues, JsonOptions.Default); // 自动序列化
|
||||
set => RangeValues = JsonSerializer.Deserialize<ObservableCollection<RangeValue>>(value, JsonOptions.Default); // 自动反序列化
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using MiniExcelLibs;
|
||||
using Newtonsoft.Json;
|
||||
using PLCSharp.Core.Prism;
|
||||
using PLCSharp.Core.Tools;
|
||||
using PLCSharp.Models;
|
||||
using PLCSharp.VVMs.Connects;
|
||||
using PLCSharp.VVMs.Connects.ModbusRtu;
|
||||
@ -64,10 +64,12 @@ namespace PLCSharp.VVMs.MainWindow
|
||||
try
|
||||
{
|
||||
var json = File.ReadAllText("./Config/EnvironmentVariable.json");
|
||||
var config = JsonConvert.DeserializeAnonymousType(json, new { EnvironmentVariables = new List<EnvironmentVariableItem>() });
|
||||
if (config?.EnvironmentVariables != null)
|
||||
var doc = System.Text.Json.JsonDocument.Parse(json);
|
||||
var arr = doc.RootElement.GetProperty("EnvironmentVariables");
|
||||
var list = System.Text.Json.JsonSerializer.Deserialize<List<EnvironmentVariableItem>>(arr.GetRawText(), PLCSharp.Core.Tools.JsonOptions.Default);
|
||||
if (list != null)
|
||||
{
|
||||
EnvironmentVariables = [.. config.EnvironmentVariables];
|
||||
EnvironmentVariables = [.. list];
|
||||
RaisePropertyChanged(nameof(EnvironmentVariables));
|
||||
}
|
||||
}
|
||||
@ -87,7 +89,7 @@ namespace PLCSharp.VVMs.MainWindow
|
||||
}
|
||||
|
||||
var config = new { EnvironmentVariables = EnvironmentVariables.ToList() };
|
||||
var json = JsonConvert.SerializeObject(config, Formatting.Indented);
|
||||
var json = System.Text.Json.JsonSerializer.Serialize(config, PLCSharp.Core.Tools.JsonOptions.Indented);
|
||||
File.WriteAllText("./Config/EnvironmentVariable.json", json);
|
||||
|
||||
SendInfoDialog("环境变量已保存");
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using PLCSharp.Core.Tools;
|
||||
using PLCSharp.Core.Common;
|
||||
using Prism.Mvvm;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
@ -370,8 +372,8 @@ namespace PLCSharp.VVMs.MotionController
|
||||
[Column("Params")]
|
||||
public string SerializedParams
|
||||
{
|
||||
get => JsonConvert.SerializeObject(Params); // 自动序列化
|
||||
set => Params = JsonConvert.DeserializeObject<AxisParams>(value); // 自动反序列化
|
||||
get => JsonSerializer.Serialize(Params, JsonOptions.Default); // 自动序列化
|
||||
set => Params = JsonSerializer.Deserialize<AxisParams>(value, JsonOptions.Default); // 自动反序列化
|
||||
|
||||
}
|
||||
private AxisParams _Params;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using PLCSharp.Core.Tools;
|
||||
using PLCSharp.Core.Common;
|
||||
using Prism.Mvvm;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
@ -291,8 +292,8 @@ namespace PLCSharp.VVMs.MotionController
|
||||
[Column("Params")]
|
||||
public string SerializedParams
|
||||
{
|
||||
get => JsonConvert.SerializeObject(Params); // 自动序列化
|
||||
set => Params = JsonConvert.DeserializeObject<AxisPointParams>(value); // 自动反序列化
|
||||
get => JsonSerializer.Serialize(Params, JsonOptions.Default); // 自动序列化
|
||||
set => Params = JsonSerializer.Deserialize<AxisPointParams>(value, JsonOptions.Default); // 自动反序列化
|
||||
}
|
||||
|
||||
private AxisPointParams _Params;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using PLCSharp.Core.Tools;
|
||||
using PLCSharp.Models;
|
||||
using Prism.Mvvm;
|
||||
@ -402,8 +403,8 @@ namespace PLCSharp.VVMs.MotionController
|
||||
[Column("Params")]
|
||||
public string SerializedParams
|
||||
{
|
||||
get => JsonConvert.SerializeObject(Params); // 自动序列化
|
||||
set => Params = JsonConvert.DeserializeObject<ControllerParams>(value); // 自动反序列化
|
||||
get => JsonSerializer.Serialize(Params, JsonOptions.Default); // 自动序列化
|
||||
set => Params = JsonSerializer.Deserialize<ControllerParams>(value, JsonOptions.Default); // 自动反序列化
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using PLCSharp.Core.Tools;
|
||||
using Prism.Mvvm;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
@ -36,10 +38,10 @@ namespace PLCSharp.VVMs.MotionController
|
||||
/// </summary>
|
||||
public string SerializedInterpolations
|
||||
{
|
||||
get => JsonConvert.SerializeObject(_InterpolationPoints); // 自动序列化
|
||||
get => JsonSerializer.Serialize(_InterpolationPoints, JsonOptions.Default); // 自动序列化
|
||||
set
|
||||
{
|
||||
InterpolationPoints = JsonConvert.DeserializeObject<ObservableCollection<InterpolationPoint>>(value); // 自动反序列化
|
||||
InterpolationPoints = JsonSerializer.Deserialize<ObservableCollection<InterpolationPoint>>(value, JsonOptions.Default); // 自动反序列化
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using PLCSharp.Core.Tools;
|
||||
using PLCSharp.Core.Common;
|
||||
using Prism.Mvvm;
|
||||
using System.Collections.ObjectModel;
|
||||
@ -102,10 +104,10 @@ namespace PLCSharp.VVMs.MotionController
|
||||
[Column("Interpolations")]
|
||||
public string SerializedInterpolations
|
||||
{
|
||||
get => JsonConvert.SerializeObject(Interpolations); // 自动序列化
|
||||
get => JsonSerializer.Serialize(Interpolations, JsonOptions.Default); // 自动序列化
|
||||
set
|
||||
{
|
||||
Interpolations = JsonConvert.DeserializeObject<ObservableCollection<Interpolation>>(value); // 自动反序列化
|
||||
Interpolations = JsonSerializer.Deserialize<ObservableCollection<Interpolation>>(value, JsonOptions.Default); // 自动反序列化
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,8 +128,8 @@ namespace PLCSharp.VVMs.MotionController
|
||||
[Column("Params")]
|
||||
public string SerializedParams
|
||||
{
|
||||
get => JsonConvert.SerializeObject(Params); // 自动序列化
|
||||
set => Params = JsonConvert.DeserializeObject<InterpolationGroupParams>(value); // 自动反序列化
|
||||
get => JsonSerializer.Serialize(Params, JsonOptions.Default); // 自动序列化
|
||||
set => Params = JsonSerializer.Deserialize<InterpolationGroupParams>(value, JsonOptions.Default); // 自动反序列化
|
||||
}
|
||||
|
||||
private InterpolationGroupParams _Params;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using Newtonsoft.Json;
|
||||
using Prism.Mvvm;
|
||||
using Prism.Mvvm;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using PLCSharp.Core.Tools;
|
||||
using PLCSharp.Core.Prism;
|
||||
using Prism.Commands;
|
||||
using Prism.Mvvm;
|
||||
@ -129,8 +130,8 @@ namespace PLCSharp.VVMs.Robots
|
||||
[Column("Params")]
|
||||
public string SerializedParams
|
||||
{
|
||||
get => JsonConvert.SerializeObject(Params);
|
||||
set => Params = JsonConvert.DeserializeObject<RobotParams>(value);
|
||||
get => JsonSerializer.Serialize(Params, JsonOptions.Default);
|
||||
set => Params = JsonSerializer.Deserialize<RobotParams>(value, JsonOptions.Default);
|
||||
|
||||
}
|
||||
|
||||
@ -246,11 +247,11 @@ namespace PLCSharp.VVMs.Robots
|
||||
{
|
||||
get
|
||||
{
|
||||
var str = JsonConvert.SerializeObject(Tools);
|
||||
var str = JsonSerializer.Serialize(Tools, JsonOptions.Default);
|
||||
|
||||
return str;
|
||||
}
|
||||
set => Tools = value != null ? JsonConvert.DeserializeObject<ObservableDictionary<int, ToolFrame4Axis>>(value) : [];
|
||||
set => Tools = value != null ? JsonSerializer.Deserialize<ObservableDictionary<int, ToolFrame4Axis>>(value, JsonOptions.Default) : [];
|
||||
}
|
||||
|
||||
private int _ToolTarget;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using PLCSharp.Core.Tools;
|
||||
using Prism.Mvvm;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
@ -189,8 +190,8 @@ namespace PLCSharp.VVMs.Robots
|
||||
[Column("Params")]
|
||||
public string SerializedParams
|
||||
{
|
||||
get => JsonConvert.SerializeObject(Params);
|
||||
set => Params = JsonConvert.DeserializeObject<PointParams>(value);
|
||||
get => JsonSerializer.Serialize(Params, JsonOptions.Default);
|
||||
set => Params = JsonSerializer.Deserialize<PointParams>(value, JsonOptions.Default);
|
||||
}
|
||||
|
||||
private PointParams _Params;
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using PLCSharp.Core.Tools;
|
||||
using OpenCvSharp;
|
||||
using Prism.Commands;
|
||||
using Prism.Mvvm;
|
||||
@ -73,8 +75,8 @@ namespace PLCSharp.VVMs.Vision.Camera
|
||||
[Column("Params")]
|
||||
public string SerializedParams
|
||||
{
|
||||
get => JsonConvert.SerializeObject(Params); // 自动序列化
|
||||
set => Params = JsonConvert.DeserializeObject<CameraParams>(value); // 自动反序列化
|
||||
get => JsonSerializer.Serialize(Params, JsonOptions.Default); // 自动序列化
|
||||
set => Params = JsonSerializer.Deserialize<CameraParams>(value, JsonOptions.Default); // 自动反序列化
|
||||
|
||||
}
|
||||
//-------------------------------------------------------NotMapped--------------------------------------------
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using OpenCvSharp;
|
||||
using Prism.Mvvm;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Prism.Mvvm;
|
||||
|
||||
namespace PLCSharp.VVMs.Vision
|
||||
@ -59,7 +60,7 @@ namespace PLCSharp.VVMs.Vision
|
||||
else
|
||||
{
|
||||
if (value == null) break ;
|
||||
r = JsonConvert.DeserializeObject<Pos>(value.ToString());
|
||||
r = JsonSerializer.Deserialize<Pos>(value.ToString(), PLCSharp.Core.Tools.JsonOptions.Default);
|
||||
}
|
||||
SetProperty(ref _RawValue, r);
|
||||
}
|
||||
@ -74,7 +75,7 @@ namespace PLCSharp.VVMs.Vision
|
||||
else
|
||||
{
|
||||
if (value == null) break;
|
||||
r = JsonConvert.DeserializeObject<Line>(value.ToString());
|
||||
r = JsonSerializer.Deserialize<Line>(value.ToString(), PLCSharp.Core.Tools.JsonOptions.Default);
|
||||
}
|
||||
SetProperty(ref _RawValue, r);
|
||||
}
|
||||
@ -89,7 +90,7 @@ namespace PLCSharp.VVMs.Vision
|
||||
else
|
||||
{
|
||||
if (value == null) break;
|
||||
r = JsonConvert.DeserializeObject<Circle>(value.ToString());
|
||||
r = JsonSerializer.Deserialize<Circle>(value.ToString(), PLCSharp.Core.Tools.JsonOptions.Default);
|
||||
}
|
||||
SetProperty(ref _RawValue, r);
|
||||
}
|
||||
@ -104,7 +105,7 @@ namespace PLCSharp.VVMs.Vision
|
||||
else
|
||||
{
|
||||
if (value == null) break;
|
||||
r = JsonConvert.DeserializeObject<Rect>(value.ToString());
|
||||
r = JsonSerializer.Deserialize<Rect>(value.ToString(), PLCSharp.Core.Tools.JsonOptions.Default);
|
||||
}
|
||||
|
||||
SetProperty(ref _RawValue, r);
|
||||
@ -123,7 +124,7 @@ namespace PLCSharp.VVMs.Vision
|
||||
else
|
||||
{
|
||||
if (value == null) break;
|
||||
r = JsonConvert.DeserializeObject<Barcode>(value.ToString());
|
||||
r = JsonSerializer.Deserialize<Barcode>(value.ToString(), PLCSharp.Core.Tools.JsonOptions.Default);
|
||||
}
|
||||
|
||||
SetProperty(ref _RawValue, r);
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#nullable enable
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using PLCSharp.Core.Tools;
|
||||
using PLCSharp.Core.Common;
|
||||
using PLCSharp.Core.Prism;
|
||||
using PLCSharp.VVMs.Vision.Camera;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using System.Text.Json;
|
||||
using PLCSharp.Core.Tools;
|
||||
using OpenCvSharp;
|
||||
using PLCSharp.Core.Common;
|
||||
using PLCSharp.Core.Prism;
|
||||
@ -195,12 +196,12 @@ namespace PLCSharp.VVMs.Vision
|
||||
[Column("VisionParams")]
|
||||
public string SerializedVisionParams
|
||||
{
|
||||
get => JsonConvert.SerializeObject(Params); // 自动序列化
|
||||
get => JsonSerializer.Serialize(Params, JsonOptions.Default); // 自动序列化
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
Params = value != null ? JsonConvert.DeserializeObject<VisionParams>(value) : new VisionParams(); // 自动反序列化
|
||||
Params = value != null ? JsonSerializer.Deserialize<VisionParams>(value, JsonOptions.Default) ?? new VisionParams() : new VisionParams(); // 自动反序列化
|
||||
}
|
||||
catch (global::System.Exception)
|
||||
{
|
||||
@ -233,8 +234,8 @@ namespace PLCSharp.VVMs.Vision
|
||||
[Column("VisionFlows")]
|
||||
public string SerializedVisionFlows
|
||||
{
|
||||
get => JsonConvert.SerializeObject(VisionFlows); // 自动序列化
|
||||
set => VisionFlows = JsonConvert.DeserializeObject<ObservableCollection<VisionFlow>>(value); // 自动反序列化
|
||||
get => JsonSerializer.Serialize(VisionFlows, JsonOptions.Default); // 自动序列化
|
||||
set => VisionFlows = JsonSerializer.Deserialize<ObservableCollection<VisionFlow>>(value, JsonOptions.Default) ?? []; // 自动反序列化
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user