IRawElementProviderSimple.GetPatternProvider(Int32) 方法

定义

检索一个 对象,该对象为 UI 自动化 元素上的控件模式提供支持。

public:
 System::Object ^ GetPatternProvider(int patternId);
public object GetPatternProvider (int patternId);
abstract member GetPatternProvider : int -> obj
Public Function GetPatternProvider (patternId As Integer) As Object

参数

patternId
Int32

模式的标识符。

返回

实现模式接口的对象;如果不支持模式,则为 null

示例

以下示例演示了仅InvokePattern支持 的GetPatternProvider提供程序的 实现。

/// <summary>
/// Returns the object that supports the specified pattern.
/// </summary>
/// <param name="patternId">ID of the pattern.</param>
/// <returns>Object that implements IInvokeProvider.</returns>
object IRawElementProviderSimple.GetPatternProvider(int patternId)
{
    if (patternId == InvokePatternIdentifiers.Pattern.Id)
    {
        // Return an object that implements IInvokeProvider.
        return myInvokePatternProvider;
    }
    else
    {
        return null;
    }
}
''' <summary>
''' Returns the object that supports the specified pattern.
''' </summary>
''' <param name="patternId">ID of the pattern.</param>
''' <returns>Object that implements IInvokeProvider.</returns>
Function GetPatternProvider(ByVal patternId As Integer) As Object _
    Implements IRawElementProviderSimple.GetPatternProvider
    If patternId = InvokePatternIdentifiers.Pattern.Id Then
        ' Return an object that implements IInvokeProvider.
        Return myInvokePatternProvider
    Else
        Return Nothing
    End If

End Function 'IRawElementProviderSimple.GetPatternProvider

适用于

另请参阅