Share via


XamlTypeInvoker.GetAddMethod(XamlType) 方法

定義

針對與集合或字典相關的 XamlTypeInvoker,傳回相關的 Add 方法。

public:
 virtual System::Reflection::MethodInfo ^ GetAddMethod(System::Xaml::XamlType ^ contentType);
public virtual System.Reflection.MethodInfo GetAddMethod (System.Xaml.XamlType contentType);
abstract member GetAddMethod : System.Xaml.XamlType -> System.Reflection.MethodInfo
override this.GetAddMethod : System.Xaml.XamlType -> System.Reflection.MethodInfo
Public Overridable Function GetAddMethod (contentType As XamlType) As MethodInfo

參數

contentType
XamlType

Add 方法所使用項目型別的 XamlType

傳回

MethodInfo

Add 方法的 CLR MethodInfo 資訊,或 Null。

例外狀況

contentTypenull

備註

這個方法應該會針對這個 XamlTypeInvoker 不是可寫入的集合或字典的情況 XamlType 傳回 null 。 具體而言,應該針對傳回 的 XamlType.LookupCollectionKind 案例傳回 。 None null

重要

如果您未存取完全信任的 XAML 類型系統,這個方法可能會向呼叫端回報誤 MethodInfo 判資訊。

給繼承者的注意事項

基底實作會針對 以未知 為基礎的案例 XamlTypeInvoker 傳回 null ,其中包含 的 為 null 的案例 UnderlyingType XamlTypeXamlType 如果 為 ItemType null ,它也會傳 null 回 。

XAML 集合可能有多個 Add 方法,因為 XAML 集合可能支援多個內容類型, (請參閱 AllowedContentTypes ,或查看 ContentWrapperAttribute WPF) 中這個概念的一個實作相關資訊。 預設實作會使用內部邏輯,根據提供的 contentType 簽章和型別傳回最佳相符專案。

適用於