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) });
|
}
|
}
|
}
|
|
}
|
}
|