AutomationElement.GetCachedPropertyValue 메서드

정의

AutomationElement에서 지정된 속성의 캐시된 값을 검색합니다.Retrieves the cached value of the specified property from an AutomationElement.

오버로드

GetCachedPropertyValue(AutomationProperty)

AutomationElement의 캐시에서 지정된 속성의 값을 검색합니다.Retrieves the value of the specified property from the cache of this AutomationElement. 대상 UI(사용자 인터페이스)user interface (UI) 요소에서 해당 속성을 명시적으로 지원하지 않는 경우에는 속성 형식의 적절한 기본값이 반환됩니다.An appropriate default value for the property type is returned for properties not explicitly supported by the target UI(사용자 인터페이스)user interface (UI) element.

GetCachedPropertyValue(AutomationProperty, Boolean)

AutomationElement의 캐시에서 지정된 속성의 값을 검색하고, 기본 속성을 선택적으로 무시할 수 있습니다.Retrieves the value of the specified property from the cache of this AutomationElement, optionally ignoring any default property.

설명

GetCachedPropertyValue 지정된 된 속성의 캐시에서 검색 된 AutomationElement합니다.GetCachedPropertyValue retrieves the specified property from the cache of the AutomationElement. 현재 속성을 검색 하려면 호출 GetCurrentPropertyValue합니다.To retrieve the current property, call GetCurrentPropertyValue.

GetCachedPropertyValue(AutomationProperty)

AutomationElement의 캐시에서 지정된 속성의 값을 검색합니다.Retrieves the value of the specified property from the cache of this AutomationElement. 대상 UI(사용자 인터페이스)user interface (UI) 요소에서 해당 속성을 명시적으로 지원하지 않는 경우에는 속성 형식의 적절한 기본값이 반환됩니다.An appropriate default value for the property type is returned for properties not explicitly supported by the target UI(사용자 인터페이스)user interface (UI) element.

public:
 System::Object ^ GetCachedPropertyValue(System::Windows::Automation::AutomationProperty ^ property);
public object GetCachedPropertyValue (System.Windows.Automation.AutomationProperty property);
member this.GetCachedPropertyValue : System.Windows.Automation.AutomationProperty -> obj
Public Function GetCachedPropertyValue (property As AutomationProperty) As Object

매개 변수

property
AutomationProperty

검색할 속성의 식별자입니다.The identifier of the property to retrieve.

반환

지정된 속성의 값이 들어 있는 개체입니다.An object containing the value of the specified property.

예외

요청한 속성이 캐시에 없습니다.The requested property is not in the cache.

AutomationElement에 대한 UI(사용자 인터페이스)user interface (UI)가 더 이상 존재하지 않는 경우The UI(사용자 인터페이스)user interface (UI) for the AutomationElement no longer exists.

예제

다음 캐시 된 속성을 검색 하려면이 메서드를 사용할 수 하는 방법을 보여 줍니다.The following shows how this method can be used to retrieve a cached property.

/// <summary>
/// Caches and retrieves properties for a list item by using CacheRequest.Push.
/// </summary>
/// <param name="autoElement">Element from which to retrieve a child element.</param>
/// <remarks>
/// This code demonstrates various aspects of caching. It is not intended to be 
/// an example of a useful method.
/// </remarks>
private void CachePropertiesByPush(AutomationElement elementList)
{
    // Set up the request.
    CacheRequest cacheRequest = new CacheRequest();

    // Do not get a full reference to the cached objects, only to their cached properties and patterns.
    cacheRequest.AutomationElementMode = AutomationElementMode.None;

    // Cache all elements, regardless of whether they are control or content elements.
    cacheRequest.TreeFilter = Automation.RawViewCondition;

    // Property and pattern to cache.
    cacheRequest.Add(AutomationElement.NameProperty);
    cacheRequest.Add(SelectionItemPattern.Pattern);

    // Activate the request.
    cacheRequest.Push();

    // Obtain an element and cache the requested items.
    Condition cond = new PropertyCondition(AutomationElement.IsSelectionItemPatternAvailableProperty, true);
    AutomationElement elementListItem = elementList.FindFirst(TreeScope.Children, cond);

    // At this point, you could call another method that creates a CacheRequest and calls Push/Pop.
    // While that method was retrieving automation elements, the CacheRequest set in this method 
    // would not be active. 

    // Deactivate the request.
    cacheRequest.Pop();

    // Retrieve the cached property and pattern.
    String itemName = elementListItem.Cached.Name;
    SelectionItemPattern pattern = elementListItem.GetCachedPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;

    // The following is an alternative way of retrieving the Name property.
    itemName = elementListItem.GetCachedPropertyValue(AutomationElement.NameProperty) as String;

    // This is yet another way, which returns AutomationElement.NotSupported if the element does
    // not supply a value. If the second parameter is false, a default name is returned.
    object objName = elementListItem.GetCachedPropertyValue(AutomationElement.NameProperty, true);
    if (objName == AutomationElement.NotSupported)
    {
        itemName = "Unknown";
    }
    else
    {
        itemName = objName as String;
    }

    // The following call raises an exception, because only the cached properties are available, 
    //  as specified by cacheRequest.AutomationElementMode. If AutomationElementMode had its
    //  default value (Full), this call would be valid.
    /*** bool enabled = elementListItem.Current.IsEnabled; ***/
}
''' <summary>
''' Caches and retrieves properties for a list item by using CacheRequest.Push.
''' </summary>
''' <param name="elementList">Element from which to retrieve a child element.</param>
''' <remarks>
''' This code demonstrates various aspects of caching. It is not intended to be 
''' an example of a useful method.
''' </remarks>
Private Sub CachePropertiesByPush(ByVal elementList As AutomationElement)
    ' Set up the request.
    Dim cacheRequest As New CacheRequest()

    ' Do not get a full reference to the cached objects, only to their cached properties and patterns.
    cacheRequest.AutomationElementMode = AutomationElementMode.None

    ' Cache all elements, regardless of whether they are control or content elements.
    cacheRequest.TreeFilter = Automation.RawViewCondition

    ' Property and pattern to cache.
    cacheRequest.Add(AutomationElement.NameProperty)
    cacheRequest.Add(SelectionItemPattern.Pattern)

    ' Activate the request.
    cacheRequest.Push()

    ' Obtain an element and cache the requested items.
    Dim myCondition As New PropertyCondition(AutomationElement.IsSelectionItemPatternAvailableProperty, _
        True)
    Dim elementListItem As AutomationElement = elementList.FindFirst(TreeScope.Children, myCondition)

    ' At this point, you could call another method that creates a CacheRequest and calls Push/Pop.
    ' While that method was retrieving automation elements, the CacheRequest set in this method 
    ' would not be active. 
    ' Deactivate the request.
    cacheRequest.Pop()

    ' Retrieve the cached property and pattern.
    Dim itemName As String = elementListItem.Cached.Name
    Dim pattern As SelectionItemPattern = _
        DirectCast(elementListItem.GetCachedPattern(SelectionItemPattern.Pattern), SelectionItemPattern)

    ' The following is an alternative way of retrieving the Name property.
    itemName = CStr(elementListItem.GetCachedPropertyValue(AutomationElement.NameProperty))

    ' This is yet another way, which returns AutomationElement.NotSupported if the element does
    ' not supply a value. If the second parameter is false, a default name is returned.
    Dim objName As Object = elementListItem.GetCachedPropertyValue(AutomationElement.NameProperty, True)
    If objName Is AutomationElement.NotSupported Then
        itemName = "Unknown"
    Else
        itemName = CStr(objName)
    End If
    ' The following call raises an exception, because only the cached properties are available, 
    '  as specified by cacheRequest.AutomationElementMode. If AutomationElementMode had its
    '  default value (Full), this call would be valid.
    '** bool enabled = elementListItem.Current.IsEnabled; **

End Sub

설명

요소 자체에 대 한 UI 자동화 공급자의 속성을 지 원하는 속성의 값이 반환 됩니다.If the UI Automation provider for the element itself supports the property, the value of the property is returned. 기본 속성을 지정 하는 고, 그렇지 UI 자동화UI Automation 반환 됩니다.Otherwise, a default property specified by UI 자동화UI Automation is returned. 참조 속성 식별자 필드의 기본 속성에 대 한 내용은 AutomationElement와 같은 AcceleratorKeyProperty합니다.For information on default properties, see the property identifier fields of AutomationElement, such as AcceleratorKeyProperty.

GetCachedPropertyValue 지정된 된 속성을 검색 합니다 AutomationElement의 캐시 합니다.GetCachedPropertyValue retrieves the specified property from the AutomationElement's cache. 지정 된 속성이 호출에 대 한 현재 개체를 가져와 GetCurrentPropertyValue합니다.To retrieve the current object for the specified property call GetCurrentPropertyValue.

이 메서드는 요청된 된 속성이 이전에 캐시 되지 않은 경우 예외가 throw 됩니다.This method throws an exception if the requested property was not previously cached.

GetCachedPropertyValue(AutomationProperty, Boolean)

AutomationElement의 캐시에서 지정된 속성의 값을 검색하고, 기본 속성을 선택적으로 무시할 수 있습니다.Retrieves the value of the specified property from the cache of this AutomationElement, optionally ignoring any default property.

public:
 System::Object ^ GetCachedPropertyValue(System::Windows::Automation::AutomationProperty ^ property, bool ignoreDefaultValue);
public object GetCachedPropertyValue (System.Windows.Automation.AutomationProperty property, bool ignoreDefaultValue);
member this.GetCachedPropertyValue : System.Windows.Automation.AutomationProperty * bool -> obj
Public Function GetCachedPropertyValue (property As AutomationProperty, ignoreDefaultValue As Boolean) As Object

매개 변수

property
AutomationProperty

검색할 속성의 식별자입니다.The identifier of the property to retrieve.

ignoreDefaultValue
Boolean

지정된 속성이 지원되지 않는 경우 기본값을 무시할지 여부를 지정하는 값입니다.A value that specifies whether a default value should be ignored if the specified property is not supported.

반환

지정된 속성의 값이 들어 있는 개체이거나, 요소에서 값을 제공하지 않고 ignoreDefaultValuetrue인 경우 NotSupported입니다.An object containing the value of the specified property, or NotSupported if the element does not supply a value and ignoreDefaultValue is true.

예외

요청한 속성이 캐시에 없습니다.The requested property is not in the cache.

AutomationElement 에 대한 UI가 더 이상 존재하지 않습니다.The UI for the AutomationElement no longer exists.

예제

다음 예제에서는 캐시 된 속성을 검색 하려면이 메서드를 사용할 수 하는 방법을 보여 줍니다.The following example shows how this method can be used to retrieve a cached property.

/// <summary>
/// Caches and retrieves properties for a list item by using CacheRequest.Push.
/// </summary>
/// <param name="autoElement">Element from which to retrieve a child element.</param>
/// <remarks>
/// This code demonstrates various aspects of caching. It is not intended to be 
/// an example of a useful method.
/// </remarks>
private void CachePropertiesByPush(AutomationElement elementList)
{
    // Set up the request.
    CacheRequest cacheRequest = new CacheRequest();

    // Do not get a full reference to the cached objects, only to their cached properties and patterns.
    cacheRequest.AutomationElementMode = AutomationElementMode.None;

    // Cache all elements, regardless of whether they are control or content elements.
    cacheRequest.TreeFilter = Automation.RawViewCondition;

    // Property and pattern to cache.
    cacheRequest.Add(AutomationElement.NameProperty);
    cacheRequest.Add(SelectionItemPattern.Pattern);

    // Activate the request.
    cacheRequest.Push();

    // Obtain an element and cache the requested items.
    Condition cond = new PropertyCondition(AutomationElement.IsSelectionItemPatternAvailableProperty, true);
    AutomationElement elementListItem = elementList.FindFirst(TreeScope.Children, cond);

    // At this point, you could call another method that creates a CacheRequest and calls Push/Pop.
    // While that method was retrieving automation elements, the CacheRequest set in this method 
    // would not be active. 

    // Deactivate the request.
    cacheRequest.Pop();

    // Retrieve the cached property and pattern.
    String itemName = elementListItem.Cached.Name;
    SelectionItemPattern pattern = elementListItem.GetCachedPattern(SelectionItemPattern.Pattern) as SelectionItemPattern;

    // The following is an alternative way of retrieving the Name property.
    itemName = elementListItem.GetCachedPropertyValue(AutomationElement.NameProperty) as String;

    // This is yet another way, which returns AutomationElement.NotSupported if the element does
    // not supply a value. If the second parameter is false, a default name is returned.
    object objName = elementListItem.GetCachedPropertyValue(AutomationElement.NameProperty, true);
    if (objName == AutomationElement.NotSupported)
    {
        itemName = "Unknown";
    }
    else
    {
        itemName = objName as String;
    }

    // The following call raises an exception, because only the cached properties are available, 
    //  as specified by cacheRequest.AutomationElementMode. If AutomationElementMode had its
    //  default value (Full), this call would be valid.
    /*** bool enabled = elementListItem.Current.IsEnabled; ***/
}
''' <summary>
''' Caches and retrieves properties for a list item by using CacheRequest.Push.
''' </summary>
''' <param name="elementList">Element from which to retrieve a child element.</param>
''' <remarks>
''' This code demonstrates various aspects of caching. It is not intended to be 
''' an example of a useful method.
''' </remarks>
Private Sub CachePropertiesByPush(ByVal elementList As AutomationElement)
    ' Set up the request.
    Dim cacheRequest As New CacheRequest()

    ' Do not get a full reference to the cached objects, only to their cached properties and patterns.
    cacheRequest.AutomationElementMode = AutomationElementMode.None

    ' Cache all elements, regardless of whether they are control or content elements.
    cacheRequest.TreeFilter = Automation.RawViewCondition

    ' Property and pattern to cache.
    cacheRequest.Add(AutomationElement.NameProperty)
    cacheRequest.Add(SelectionItemPattern.Pattern)

    ' Activate the request.
    cacheRequest.Push()

    ' Obtain an element and cache the requested items.
    Dim myCondition As New PropertyCondition(AutomationElement.IsSelectionItemPatternAvailableProperty, _
        True)
    Dim elementListItem As AutomationElement = elementList.FindFirst(TreeScope.Children, myCondition)

    ' At this point, you could call another method that creates a CacheRequest and calls Push/Pop.
    ' While that method was retrieving automation elements, the CacheRequest set in this method 
    ' would not be active. 
    ' Deactivate the request.
    cacheRequest.Pop()

    ' Retrieve the cached property and pattern.
    Dim itemName As String = elementListItem.Cached.Name
    Dim pattern As SelectionItemPattern = _
        DirectCast(elementListItem.GetCachedPattern(SelectionItemPattern.Pattern), SelectionItemPattern)

    ' The following is an alternative way of retrieving the Name property.
    itemName = CStr(elementListItem.GetCachedPropertyValue(AutomationElement.NameProperty))

    ' This is yet another way, which returns AutomationElement.NotSupported if the element does
    ' not supply a value. If the second parameter is false, a default name is returned.
    Dim objName As Object = elementListItem.GetCachedPropertyValue(AutomationElement.NameProperty, True)
    If objName Is AutomationElement.NotSupported Then
        itemName = "Unknown"
    Else
        itemName = CStr(objName)
    End If
    ' The following call raises an exception, because only the cached properties are available, 
    '  as specified by cacheRequest.AutomationElementMode. If AutomationElementMode had its
    '  default value (Full), this call would be valid.
    '** bool enabled = elementListItem.Current.IsEnabled; **

End Sub

설명

GetCachedPropertyValue 지정된 된 속성에 대 한 캐시에서 검색 된 AutomationElement합니다.GetCachedPropertyValue retrieves the specified property from the cache for the AutomationElement. 현재 속성을 검색 하려면 호출 GetCurrentPropertyValue합니다.To retrieve the current property, call GetCurrentPropertyValue.

전달 falseignoreDefaultValue 호출 하는 것과 같습니다 AutomationElement.GetCachedPropertyValue(AutomationProperty)합니다.Passing false in ignoreDefaultValue is equivalent to calling AutomationElement.GetCachedPropertyValue(AutomationProperty).

요소 자체에 대 한 UI 자동화 공급자의 속성을 지 원하는 속성의 값이 반환 됩니다.If the UI Automation provider for the element itself supports the property, the value of the property is returned. 그렇지 않은 경우, ignoreDefaultValue 됩니다 false, 지정 된 기본 속성을 UI 자동화UI Automation 반환 됩니다.Otherwise, if ignoreDefaultValue is false, a default property specified by UI 자동화UI Automation is returned. 참조 속성 식별자 필드의 기본 속성에 대 한 내용은 AutomationElement와 같은 AcceleratorKeyProperty합니다.For information on default properties, see the property identifier fields of AutomationElement, such as AcceleratorKeyProperty.

이 메서드는 요청된 된 속성이 이전에 캐시 되지 않은 경우 예외가 throw 됩니다.This method throws an exception if the requested property was not previously cached.

적용 대상