ActionResultObjectValueAttribute 類別

定義

在 ActionResult 建構函式、協助程式方法參數和屬性上標注的屬性,以指出參數或屬性是用來設定 ActionResult 的 「value」。

分析器會依類型名稱比對此參數。 這可讓使用者標注具有使用者定義屬性的自訂結果 \ 自訂協助程式,而不需要公開此類型。

此屬性刻意標示為 Inherited=false,因為分析器不會引導繼承圖表。

public ref class ActionResultObjectValueAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Parameter | System.AttributeTargets.Property, AllowMultiple=false, Inherited=false)]
public sealed class ActionResultObjectValueAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Parameter | System.AttributeTargets.Property, AllowMultiple=false, Inherited=false)>]
type ActionResultObjectValueAttribute = class
    inherit Attribute
Public NotInheritable Class ActionResultObjectValueAttribute
Inherits Attribute
繼承
ActionResultObjectValueAttribute
屬性

範例

批註建構函式參數:

public BadRequestObjectResult([ActionResultObjectValue] object error)
    :base(error)
{
    StatusCode = DefaultStatusCode;
}

批註屬性:

public class ObjectResult : ActionResult, IStatusCodeActionResult
{
    [ActionResultObjectValue]
    public object Value { get; set; }
}

建構函式

ActionResultObjectValueAttribute()

在 ActionResult 建構函式、協助程式方法參數和屬性上標注的屬性,以指出參數或屬性是用來設定 ActionResult 的 「value」。

分析器會依類型名稱比對此參數。 這可讓使用者標注具有使用者定義屬性的自訂結果 \ 自訂協助程式,而不需要公開此類型。

此屬性刻意標示為 Inherited=false,因為分析器不會引導繼承圖表。

適用於