IntegerValidatorAttribute 类

定义

以声明方式指示 .NET 对配置属性执行整数验证。 此类不能被继承。

public ref class IntegerValidatorAttribute sealed : System::Configuration::ConfigurationValidatorAttribute
[System.AttributeUsage(System.AttributeTargets.Property)]
public sealed class IntegerValidatorAttribute : System.Configuration.ConfigurationValidatorAttribute
[<System.AttributeUsage(System.AttributeTargets.Property)>]
type IntegerValidatorAttribute = class
    inherit ConfigurationValidatorAttribute
Public NotInheritable Class IntegerValidatorAttribute
Inherits ConfigurationValidatorAttribute
继承
属性

示例

以下示例演示如何使用ConfigurationSection特性修饰自定义IntegerValidatorAttribute对象的属性。

[ConfigurationProperty("maxAttempts", DefaultValue = 101,
    IsRequired = true)]
[IntegerValidator(MinValue = 1, MaxValue = 100,
    ExcludeRange = true)]
public int MaxAttempts
{
    get
    {
        return (int)this["maxAttempts"];
    }
    set
    {
        this["maxAttempts"] = value;
    }
}
<ConfigurationProperty("maxAttempts", _
DefaultValue:=101, _
IsRequired:=True), _
IntegerValidator(MinValue:=1, _
MaxValue:=100, _
ExcludeRange:=True)> _
Public Property MaxAttempts() As Integer
    Get
        Return Fix(Me("maxAttempts"))
    End Get
    Set(ByVal value As Integer)
        Me("maxAttempts") = value
    End Set
End Property

注解

使用 IntegerValidatorAttribute 属性修饰配置属性,这将指示.NET使用 IntegerValidator 对象验证属性,并将其传递给修饰参数的值。

只能将属性应用于 IntegerValidatorAttribute 属性类型。

构造函数

名称 说明
IntegerValidatorAttribute()

创建类的新实例 IntegerValidatorAttribute

属性

名称 说明
ExcludeRange

获取或设置一个值,该值指示是包含还是排除由MinValueMaxValue属性值定义的区域中的整数。

MaxValue

获取或设置属性允许的最大值。

MinValue

获取或设置属性允许的最小值。

TypeId

在派生类中实现时,获取此 Attribute的唯一标识符。

(继承自 Attribute)
ValidatorInstance

获取类的 IntegerValidator 实例。

ValidatorType

获取验证程序属性的类型。

(继承自 ConfigurationValidatorAttribute)

方法

名称 说明
Equals(Object)

返回一个值,该值指示此实例是否等于指定对象。

(继承自 Attribute)
GetHashCode()

返回此实例的哈希代码。

(继承自 Attribute)
GetType()

获取当前实例的 Type

(继承自 Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否为派生类的默认值。

(继承自 Attribute)
Match(Object)

在派生类中重写时,返回一个值,该值指示此实例是否等于指定对象。

(继承自 Attribute)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

显式接口实现

名称 说明
_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

(继承自 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,该信息可用于获取接口的类型信息。

(继承自 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对对象公开的属性和方法的访问。

(继承自 Attribute)

适用于

另请参阅