automapper框架优化

This commit is contained in:
hsc
2026-06-10 15:04:11 +08:00
parent 5452857299
commit 2e07c0c446
43 changed files with 612 additions and 293 deletions

View File

@@ -10,7 +10,7 @@ namespace SettingModule.ViewModels.Dialogs
{
/// <summary>
/// 串口连接配置对话框 VM。
/// 通过 DialogParameters 接收宿主 DeviceInfoModel;保存时把副本写回宿主。
/// 通过 DialogParameters 接收宿主 DeviceInfoVM保存时把副本写回宿主。
/// </summary>
public class SerialPortConfigViewModel : DialogViewModelBase
{
@@ -23,8 +23,8 @@ namespace SettingModule.ViewModels.Dialogs
set => SetProperty(ref _title, value);
}
private SerialPortConnectionConfig _config = new();
public SerialPortConnectionConfig Config
private SerialPortConfigVM _config = new();
public SerialPortConfigVM Config
{
get => _config;
set => SetProperty(ref _config, value);
@@ -70,7 +70,7 @@ namespace SettingModule.ViewModels.Dialogs
public ICommand RefreshPortsCommand { get; }
#endregion
private DeviceInfoModel? _hostDevice;
private DeviceInfoVM? _hostDevice;
public SerialPortConfigViewModel(IContainerProvider containerProvider) : base(containerProvider)
{
@@ -126,7 +126,7 @@ namespace SettingModule.ViewModels.Dialogs
if (_hostDevice != null)
{
_hostDevice.SerialPortConfig ??= new SerialPortConnectionConfig();
_hostDevice.SerialPortConfig ??= new SerialPortConfigVM();
Config.CopyTo(_hostDevice.SerialPortConfig);
_hostDevice.ConnectionType = "Serial";
}
@@ -143,13 +143,13 @@ namespace SettingModule.ViewModels.Dialogs
if (parameters.ContainsKey("Device"))
{
_hostDevice = parameters.GetValue<DeviceInfoModel>("Device");
_hostDevice = parameters.GetValue<DeviceInfoVM>("Device");
Title = $"串口连接配置 - {_hostDevice?.DeviceName}";
Config = new SerialPortConnectionConfig(_hostDevice?.SerialPortConfig);
Config = new SerialPortConfigVM(_hostDevice?.SerialPortConfig);
}
else if (parameters.ContainsKey("Config"))
{
Config = new SerialPortConnectionConfig(parameters.GetValue<SerialPortConnectionConfig>("Config"));
Config = new SerialPortConfigVM(parameters.GetValue<SerialPortConfigVM>("Config"));
}
RefreshPorts();