lixiaojun
2024-03-27 56b519c5ee0ee0615400c7df8d455f9766fa600b
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
namespace Yw.Dto.Curve
{
    /// <summary>
    /// 
    /// </summary>
    public class CurveExpressInput : IValidatableObject
    {
        /// <summary>
        /// 拟合类型
        /// </summary>
        public eFitType FitType { get; set; }
 
        /// <summary>
        /// 定义点列表
        /// </summary>
        public List<CurvePoint> DefinePoints { get; set; }
 
        /// <summary>
        /// 
        /// </summary>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (DefinePoints == null || DefinePoints.Count < 1)
            {
                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) });
            }
        }
 
    }
}