lixiaojun
2023-11-08 0363984a82f507db16460a1441bf856c40e13481
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
namespace Yw.Application
{
    /// <summary>
    /// 
    /// </summary>
    public class CurveExpressToolInput : IValidatableObject
    {
        /// <summary>
        /// 拟合类型
        /// </summary>
        [Required]
        public eFitType FitType { get; set; }
 
        /// <summary>
        /// 定义点列表
        /// </summary>
        [Required]
        public List<CurvePoint> DefinePoints { get; set; }
 
        /// <summary>
        /// 点数量
        /// </summary>
        public int? PointNumber { get; set; }
 
        /// <summary>
        /// 
        /// </summary>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (DefinePoints == null || DefinePoints.Count < 4)
            {
                yield return new ValidationResult("DefinePoints 数量不足,至少4个点", new string[] { nameof(DefinePoints) });
            }
 
            var fitPow = FitHelper.GetFitPow(FitType);
            if (DefinePoints.Count < fitPow + 1)
            {
                yield return new ValidationResult($"DefinePoints 数量不足,至少{fitPow + 1}个点", new string[] { nameof(DefinePoints) });
            }
            if (PointNumber.HasValue)
            {
                if (PointNumber.Value < 6)
                {
                    yield return new ValidationResult($"PointNumber 不能小于6", new string[] { nameof(PointNumber) });
                }
            }
        }
 
    }
}