VerificationAttribute 类

定义

定义 Web 内容可访问性规则的元数据特性。Defines the metadata attribute of a Web content accessibility rule. 此类不能被继承。This class cannot be inherited.

public ref class VerificationAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Property, AllowMultiple=true)]
public sealed class VerificationAttribute : Attribute
type VerificationAttribute = class
    inherit Attribute
Public NotInheritable Class VerificationAttribute
Inherits Attribute
继承
VerificationAttribute
属性

示例

下面的代码示例演示如何使用VerificationAttribute类。The following code example demonstrates using the VerificationAttribute class. 在验证元数据定义中, 所使用的准则为 "WCAG"、"Web 内容辅助功能准则" 和 "ADA, 美国人"。In the verification metadata definition, the guidelines used are "WCAG," the Web Content Accessibility Guideline, and "ADA," Americans with Disabilities Act Guidelines. 有关详细信息, 请参阅万维网联合会 (W3C)网站。For more information, see the World Wide Web Consortium (W3C) Web site.

使用的检查点分别为 "1.1" 和 "1194.22 (a)", 分别用于 WCAG 和 ADA, 以确保非文本元素存在等效的文本。The checkpoints used are "1.1" and "1194.22(a)" for WCAG and ADA, respectively, checkpoints for ensuring that a text equivalent exists for non-text elements. 应用于属性, 该属性表示另一个名ImageProperty为的属性的等效文本。 ImageText VerificationAttributeThe VerificationAttribute is applied to the ImageText property that represents the text equivalent of another property called ImageProperty. 如果未ImageText设置该属性, 则辅助功能验证将返回消息 "图像缺少文本等效项"。If the ImageText property is not set, the accessibility verification will return the message "The image is missing a text equivalent."

[Verification("ADA", "1194.22(a)", 
    VerificationReportLevel.Error, 1,
    "The image is missing a text equivalent.", 
    VerificationRule.NotEmptyString, "ImageUrl"),
Verification("WCAG", "1.1", 
    VerificationReportLevel.Error, 1, 
    "The image is missing an text equivalent.", 
    VerificationRule.NotEmptyString, "ImageUrl")]
public virtual String ImageText
{
    get
    {
        object obj = ViewState["ImageText"];
        return ((obj == null) ? String.Empty : (string)obj);
    }
    set
    {
        ViewState["ImageText"] = value;
    }
}
public virtual String ImageUrl
{
    get 
    {
        object obj = ViewState["ImageUrl"];
        return ((obj == null) ? String.Empty : (string)obj);
    }
    set 
    { 
        ViewState["ImageUrl"] = value;
    }
}
<Verification("ADA", "1194.22(a)", VerificationReportLevel.Error, 1, "The image is missing a text equivalent.", VerificationRule.NotEmptyString, "ImageUrl")> _
<Verification("WCAG", "1.1", VerificationReportLevel.Error, 1, "The image is missing a text equivalent.", VerificationRule.NotEmptyString, "ImageUrl")> _
Public Property ImageText() As String
    Get
        If ViewState("ImageText") Is Nothing Then
            Return String.Empty
        Else
            Return CType(ViewState("ImageText"), String)
        End If
    End Get
    Set(ByVal value As String)
        ViewState("ImageText") = value
    End Set
End Property


Public Property ImageUrl() As String
    Get
        If ViewState("ImageUrl") Is Nothing Then
            Return String.Empty
        Else
            Return CType(ViewState("ImageUrl"), String)
        End If
    End Get
    Set(ByVal value As String)
        ViewState("ImageUrl") = value
    End Set
End Property

注解

VerificationAttribute类的实例定义可以验证的 Web 内容可访问性规则。An instance of the VerificationAttribute class defines a Web content accessibility rule that can be verified. 有关 Web 内容辅助功能准则的详细信息, 请参阅万维网联合会 (W3C)网站。For more information on Web Content Accessibility Guidelines, see the World Wide Web Consortium (W3C) Web site.

定义实例VerificationAttribute所需的最少信息量包括:The minimal amount of information required to define an instance of a VerificationAttribute includes:

  • 验证规则表示的准则。A guideline that the verification rule represents. 构造函数中指定的值设置Guideline属性。The value specified in the constructor sets the Guideline property.

  • 准则的检查点。A checkpoint of the guideline. 构造函数中指定的值设置Checkpoint属性。The value specified in the constructor sets the Checkpoint property.

  • 检查点优先级。A checkpoint priority. 构造函数中指定的值设置Priority属性。The value specified in the constructor sets the Priority property.

  • 一个VerificationReportLevel枚举值, 该值表示应作为规则所属的报表级别。A VerificationReportLevel enumeration value that represents the reporting level that should be rule belongs to. 构造函数中指定的值设置VerificationReportLevel属性。The value specified in the constructor sets the VerificationReportLevel property.

  • 验证规则为 true 时报告的消息。A message that is reported when the verification rule is true. 构造函数中指定的值设置Message属性。The value specified in the constructor sets the Message property.

可以在创建实例时指定的验证规则的可选属性:Optional properties of the verification rule that can be specified when creating an instance:

  • 一个VerificationRule枚举值, 该值表示应如何解释验证规则。A VerificationRule enumeration value that represents how the verification rule should be interpreted. 构造函数中指定的值设置VerificationRule属性。The value specified in the constructor sets the VerificationRule property.

  • 一个VerificationConditionalOperator枚举值, 该值表示用于测试验证规则的条件表达式中的运算符。A VerificationConditionalOperator enumeration value that represents the operator in the conditional expression used to test the verification rule. 构造函数中指定的值设置VerificationConditionalOperator属性。The value specified in the constructor sets the VerificationConditionalOperator property.

  • 可访问性引用指导性 URL。An accessibility reference guideline URL. 构造函数中指定的值设置GuidelineUrl属性。The value specified in the constructor sets the GuidelineUrl property.

  • 一个条件值, 它表示条件表达式的右侧。A conditional value representing the right side of a conditional expression. 构造函数中指定的值设置ConditionalValue属性。The value specified in the constructor sets the ConditionalValue property.

  • 一个条件属性, 表示条件表达式的左侧。A conditional property representing the left side of a conditional expression. 构造函数中指定的值设置ConditionalProperty属性。The value specified in the constructor sets the ConditionalProperty property.

可以VerificationAttribute定义元数据的类、属性和索引器声明。The VerificationAttribute metadata can be defined class, property, and indexer declarations.

有关使用特性的详细信息, 请参阅特性For more information about using attributes, see Attributes.

构造函数

VerificationAttribute(String, String, VerificationReportLevel, Int32, String)

使用可访问性准则、检查点、报告级别、检查点优先级和错误信息初始化 VerificationAttribute 类的新实例。Initializes a new instance of the VerificationAttribute class with accessibility guideline, checkpoint, reporting level, checkpoint priority, and error message.

VerificationAttribute(String, String, VerificationReportLevel, Int32, String, VerificationRule, String)

使用可访问性准则、检查点、报告级别、检查点优先级、错误信息、VerificationRule 值和相关条件属性初始化 VerificationAttribute 类的新实例。Initializes a new instance of the VerificationAttribute class with accessibility guideline, checkpoint, reporting level, checkpoint priority, error message, VerificationRule.value, and related conditional property.

VerificationAttribute(String, String, VerificationReportLevel, Int32, String, VerificationRule, String, VerificationConditionalOperator, String, String)

使用可访问性准则、检查点、报告级别、检查点优先级、错误信息、VerificationRule 值、相关条件属性、相关条件属性值和引用准则 URL 初始化 VerificationAttribute 类的新实例。Initializes a new instance of the VerificationAttribute class with accessibility guideline, checkpoint, reporting level, checkpoint priority, error message, VerificationRule.value, related conditional property, a related conditional property value, and a reference guideline URL.

属性

Checkpoint

获取指定的 Guideline 属性中的可访问性检查点引用。Gets the accessibility checkpoint reference in the specified Guideline property.

ConditionalProperty

获取用作验证可访问性检查点的一部分的条件表达式的左侧。Gets the left side of a conditional expression used as part of the verification accessibility checkpoint.

ConditionalValue

获取用作验证可访问性检查点的一部分的条件表达式的右侧。Gets the right side of a conditional expression used as part of the verification accessibility checkpoint.

Guideline

获取用于可访问性检查的准则。Gets the guideline that used for accessibility checking.

GuidelineUrl

获取 URL,该 URL 可用于获取有关 Guideline 属性中给定的可访问性准则的更多信息。Gets the URL the can be used to get more information on the accessibility guidelines given in the Guideline property.

Message

获取当可访问性检查点验证规则为 true 时的消息字符串。Gets a message string when the accessibility checkpoint verification rule is true.

Priority

获取可访问性检查点的优先级。Gets the priority of the accessibility checkpoint.

TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。When implemented in a derived class, gets a unique identifier for this Attribute.

(继承自 Attribute)
VerificationConditionalOperator

获取一个 VerificationConditionalOperator 枚举值,该值指示可访问性检查点的验证方式。Gets a VerificationConditionalOperator enumeration value indication how the accessibility checkpoint is verified.

VerificationReportLevel

获取一个 VerificationReportLevel 枚举值,该值指示可访问性检查点的使用方式。Gets a VerificationReportLevel enumeration value indicating how the accessibility checkpoint is used.

VerificationRule

获取一个 VerificationRule 枚举值,该值指示可访问性检查点的使用方式。Gets a VerificationRule enumeration value indicating how the accessibility checkpoint is used.

方法

Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object.

(继承自 Attribute)
GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

(继承自 Attribute)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(继承自 Attribute)
Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(继承自 Attribute)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

显式界面实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

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

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can be used to get the type information for an interface.

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

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

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

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(继承自 Attribute)

适用于

另请参阅