61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
namespace QuickModeling.Models
|
|
{
|
|
[JsonObject(MemberSerialization.OptIn)]
|
|
public partial class ComponentConfig : ObservableValidator, ICloneable
|
|
{
|
|
private ComponentType componentType;
|
|
|
|
private string description;
|
|
|
|
private bool isEnabled = true;
|
|
|
|
private string name;
|
|
|
|
public object Clone()
|
|
{
|
|
var copy = (ComponentConfig)MemberwiseClone();
|
|
copy.Guid = Guid.NewGuid();
|
|
copy.Parameters = new ObservableCollection<Parameter>(Parameters.Select(p => p.Clone() as Parameter));
|
|
return copy;
|
|
}
|
|
[JsonProperty]
|
|
public Guid Guid { get; set; }
|
|
/// <summary>
|
|
/// 配置名称
|
|
/// </summary>
|
|
[Required(ErrorMessage = "配置名称不能为空")]
|
|
[MinLength(1, ErrorMessage = "配置名称不能为空")]
|
|
[JsonProperty]
|
|
public string Name { get => name; set => SetProperty(ref name, value, true); }
|
|
|
|
[JsonProperty]
|
|
public ComponentType ComponentType { get => componentType; set => SetProperty(ref componentType, value); }
|
|
/// <summary>
|
|
/// 配置描述
|
|
/// </summary>
|
|
[JsonProperty]
|
|
public string Description { get => description; set => SetProperty(ref description, value); }
|
|
|
|
[JsonProperty]
|
|
public bool IsEnabled { get => isEnabled; set => SetProperty(ref isEnabled, value); }
|
|
|
|
/// <summary>
|
|
/// 参数
|
|
/// </summary>
|
|
[JsonProperty]
|
|
public ObservableCollection<Parameter> Parameters { get; set; } = new ObservableCollection<Parameter>();
|
|
}
|
|
}
|