VerificationAttribute 類別

定義

定義無障礙網頁開發規則的中繼資料屬性。 此類別無法獲得繼承。

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」,美國殘障人士法案指導方針。 如需詳細資訊,請參閱 World Wide Web Consortium (W3C) 網站

使用的檢查點分別是 「1.1」 和 「1194.22 (WCAG 和 ADA 的) 」,分別用於確保非文字元素的文字對等專案存在。 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 內容協助工具指導方針的詳細資訊,請參閱 World Wide Web Consortium (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)

使用協助工具方針、檢查點、報告層級、檢查點優先權、錯誤訊息、VerificationAttribute.value,以及相關條件屬性,初始化 VerificationRule 類別的新執行個體。

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

使用協助工具方針、檢查點、報告層級、檢查點優先權、錯誤訊息、VerificationAttribute.value、相關條件屬性、相關條件屬性值,以及參考方針 URL,初始化 VerificationRule 類別的新執行個體。

屬性

Checkpoint

取得指定之 Guideline 屬性中的協助工具檢查點參考。

ConditionalProperty

取得條件運算式的左邊,用做驗證協助工具檢查點的一部分。

ConditionalValue

取得條件運算式的右邊,用做驗證協助工具檢查點的一部分。

Guideline

取得用於檢查協助工具的方針。

GuidelineUrl

取得 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)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。

(繼承來源 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。

(繼承來源 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

擷取物件提供的類型資訊介面數目 (0 或 1)。

(繼承來源 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開的屬性和方法的存取權。

(繼承來源 Attribute)

適用於

另請參閱