CadParamPluging/Common/TemplateSchemaDefinition.cs
2025-12-17 10:04:08 +08:00

49 lines
1.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
namespace CadParamPluging.Common
{
[Serializable]
public class TemplateSchemaDefinition
{
public string TemplateKey { get; set; }
public string ProjectType { get; set; }
public string DrawingType { get; set; }
public string SheetSize { get; set; }
public string Scale { get; set; }
public string DisplayName { get; set; }
public List<string> SelectedParamKeys { get; set; }
public TemplateSchemaDefinition()
{
SelectedParamKeys = new List<string>();
}
public void Normalize()
{
ProjectType = (ProjectType ?? string.Empty).Trim();
DrawingType = (DrawingType ?? string.Empty).Trim();
SheetSize = (SheetSize ?? string.Empty).Trim();
Scale = (Scale ?? string.Empty).Trim();
DisplayName = (DisplayName ?? string.Empty).Trim();
TemplateKey = TemplateKeyBuilder.Build(ProjectType, DrawingType, SheetSize, Scale);
if (SelectedParamKeys == null)
{
SelectedParamKeys = new List<string>();
}
SelectedParamKeys = SelectedParamKeys
.Where(s => !string.IsNullOrWhiteSpace(s))
.Select(s => s.Trim())
.Distinct(StringComparer.OrdinalIgnoreCase)
.ToList();
}
}
}