84 lines
2.4 KiB
C#
84 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace CadParamPluging.Common
|
|
{
|
|
[Serializable]
|
|
public class ParamDefinition
|
|
{
|
|
public string Key { get; set; }
|
|
public string Label { get; set; }
|
|
public ParamValueType Type { get; set; }
|
|
public bool Required { get; set; }
|
|
|
|
/// <summary>
|
|
/// Free-form note, typically the original "填写方式".
|
|
/// </summary>
|
|
public string Hint { get; set; }
|
|
|
|
/// <summary>
|
|
/// Stored as string for XML friendliness.
|
|
/// </summary>
|
|
public string DefaultValue { get; set; }
|
|
|
|
/// <summary>
|
|
/// Numeric constraints stored as string for XML friendliness.
|
|
/// </summary>
|
|
public string Min { get; set; }
|
|
public string Max { get; set; }
|
|
|
|
public List<string> EnumOptions { get; set; }
|
|
|
|
public string Group { get; set; }
|
|
public int Order { get; set; }
|
|
|
|
public ParamDefinition()
|
|
{
|
|
EnumOptions = new List<string>();
|
|
}
|
|
|
|
public ParamDefinition Clone()
|
|
{
|
|
return new ParamDefinition
|
|
{
|
|
Key = Key,
|
|
Label = Label,
|
|
Type = Type,
|
|
Required = Required,
|
|
Hint = Hint,
|
|
DefaultValue = DefaultValue,
|
|
Min = Min,
|
|
Max = Max,
|
|
EnumOptions = (EnumOptions ?? new List<string>()).ToList(),
|
|
Group = Group,
|
|
Order = Order
|
|
};
|
|
}
|
|
|
|
public void Normalize()
|
|
{
|
|
Key = (Key ?? string.Empty).Trim();
|
|
Label = (Label ?? string.Empty).Trim();
|
|
Hint = (Hint ?? string.Empty).Trim();
|
|
DefaultValue = (DefaultValue ?? string.Empty).Trim();
|
|
Min = (Min ?? string.Empty).Trim();
|
|
Max = (Max ?? string.Empty).Trim();
|
|
Group = (Group ?? string.Empty).Trim();
|
|
|
|
if (EnumOptions != null)
|
|
{
|
|
EnumOptions = EnumOptions
|
|
.Where(s => !string.IsNullOrWhiteSpace(s))
|
|
.Select(s => s.Trim())
|
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
|
.ToList();
|
|
}
|
|
else
|
|
{
|
|
EnumOptions = new List<string>();
|
|
}
|
|
}
|
|
}
|
|
}
|