修改命名空间
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Globalization;
|
||||
|
||||
|
||||
namespace ShrlAlgoToolkit.RevitAddins.Common.Attributes;
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
|
||||
public sealed class IsNumericAttribute : ValidationAttribute
|
||||
{
|
||||
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
|
||||
{
|
||||
return double.TryParse(value.ToString(), out var _) ? ValidationResult.Success : new("输入内容不是数值。");
|
||||
}
|
||||
public override bool IsValid(object value)
|
||||
{
|
||||
return double.TryParse(value.ToString(), out var _);
|
||||
}
|
||||
public override string FormatErrorMessage(string name)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, base.ErrorMessageString, [name]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user