ParameterInfo.GetCustomAttributesData 方法

定義

傳回目前參數的 CustomAttributeData 物件清單,這些物件可用於僅限反映的內容中。Returns a list of CustomAttributeData objects for the current parameter, which can be used in the reflection-only context.

public:
 virtual System::Collections::Generic::IList<System::Reflection::CustomAttributeData ^> ^ GetCustomAttributesData();
public virtual System.Collections.Generic.IList<System.Reflection.CustomAttributeData> GetCustomAttributesData ();
abstract member GetCustomAttributesData : unit -> System.Collections.Generic.IList<System.Reflection.CustomAttributeData>
override this.GetCustomAttributesData : unit -> System.Collections.Generic.IList<System.Reflection.CustomAttributeData>
Public Overridable Function GetCustomAttributesData () As IList(Of CustomAttributeData)

傳回

IList<CustomAttributeData>

CustomAttributeData 物件的泛型清單,表示已套用至目前參數之屬性的資料。A generic list of CustomAttributeData objects representing data about the attributes that have been applied to the current parameter.

備註

在僅限反映的內容中,您可以使用這個方法來檢查程式碼的自訂屬性,以在自訂屬性本身是在載入僅限反映內容的程式碼中定義的情況。Use this method to examine the custom attributes of code in the reflection-only context, in cases where the custom attributes themselves are defined in code that is loaded into the reflection-only context. 方法(例如 Attribute.GetCustomAttributesParameterInfo.GetCustomAttributes )無法在這種情況下使用,因為它們會建立屬性的實例。Methods such as Attribute.GetCustomAttributes and ParameterInfo.GetCustomAttributes cannot be used in such cases, because they create instances of the attributes. 無法執行僅限反映內容中的程式碼。Code in the reflection-only context cannot be executed. 如需詳細資訊和範例程式碼,請參閱 CustomAttributeData 類別。For more information and example code, see the CustomAttributeData class.

適用於