VerificationAttribute 类

定义

定义 Web 内容可访问性规则的元数据特性。 此类不能被继承。

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

示例

下面的代码示例演示如何使用 VerificationAttribute 类。 在验证元数据定义中,使用的准则是“WCAG”、Web 内容辅助功能指南和“ADA”,即美国残疾人法案指南。 有关详细信息,请参阅 万维网联合会 (W3C) 网站

用于 WCAG 和 ADA 的检查点分别为“1.1”和“1194.22 () ”,用于确保存在非文本元素的文本等效项。 将 VerificationAttribute 应用于 ImageText 表示另一个名为 ImageProperty的属性的等效文本的属性。 ImageText如果未设置 属性,辅助功能验证将返回消息“图像缺少等效文本”。

[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 内容辅助功能规则。 有关 Web 内容辅助功能指南的详细信息,请参阅 万维网联盟 (W3C) 网站

定义 实例 VerificationAttribute 所需的最少信息量包括:

  • 验证规则表示的准则。 构造函数中指定的值将设置 Guideline 属性。

  • 指南的检查点。 构造函数中指定的值将设置 Checkpoint 属性。

  • 检查点优先级。 构造函数中指定的值将设置 Priority 属性。

  • 一个 VerificationReportLevel 枚举值,该值表示应是规则所属的报告级别。 构造函数中指定的值将设置 VerificationReportLevel 属性。

  • 验证规则为 true 时报告的消息。 构造函数中指定的值将设置 Message 属性。

创建实例时可以指定的验证规则的可选属性:

VerificationAttribute元数据可以定义类、属性和索引器声明。

有关使用特性的详细信息,请参阅 特性

构造函数

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

使用可访问性准则、检查点、报告级别、检查点优先级和错误信息初始化 VerificationAttribute 类的新实例。

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

使用可访问性准则、检查点、报告级别、检查点优先级、错误信息、VerificationRule 值和相关条件属性初始化 VerificationAttribute 类的新实例。

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

使用可访问性准则、检查点、报告级别、检查点优先级、错误信息、VerificationRule 值、相关条件属性、相关条件属性值和引用准则 URL 初始化 VerificationAttribute 类的新实例。

属性

Checkpoint

获取指定的 Guideline 属性中的可访问性检查点引用。

ConditionalProperty

获取用作验证可访问性检查点的一部分的条件表达式的左侧。

ConditionalValue

获取用作验证可访问性检查点的一部分的条件表达式的右侧。

Guideline

获取用于可访问性检查的准则。

GuidelineUrl

获取 URL,该 URL 可用于获取有关 Guideline 属性中给定的可访问性准则的更多信息。

Message

获取当可访问性检查点验证规则为 true 时的消息字符串。

Priority

获取可访问性检查点的优先级。

TypeId

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

(继承自 Attribute)
VerificationConditionalOperator

获取一个 VerificationConditionalOperator 枚举值,该值指示可访问性检查点的验证方式。

VerificationReportLevel

获取一个 VerificationReportLevel 枚举值,该值指示可访问性检查点的使用方式。

VerificationRule

获取一个 VerificationRule 枚举值,该值指示可访问性检查点的使用方式。

方法

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)

适用于

另请参阅