AutomationElement.GetCachedPropertyValue 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
에서 지정된 속성의 캐시된 값을 검색합니다 AutomationElement.
오버로드
| Name | Description |
|---|---|
| GetCachedPropertyValue(AutomationProperty) |
이 AutomationElement캐시에서 지정된 속성의 값을 검색합니다. 대상 UI(사용자 인터페이스) 요소에서 명시적으로 지원되지 않는 속성에 대해 속성 형식에 대한 적절한 기본값이 반환됩니다. |
| GetCachedPropertyValue(AutomationProperty, Boolean) |
이 캐시에서 AutomationElement지정된 속성의 값을 검색하고 필요에 따라 기본 속성을 무시합니다. |
설명
GetCachedPropertyValue 는 .의 캐시에서 지정된 속성을 검색합니다 AutomationElement. 현재 속성을 검색하려면 .를 호출 GetCurrentPropertyValue합니다.
GetCachedPropertyValue(AutomationProperty)
이 AutomationElement캐시에서 지정된 속성의 값을 검색합니다. 대상 UI(사용자 인터페이스) 요소에서 명시적으로 지원되지 않는 속성에 대해 속성 형식에 대한 적절한 기본값이 반환됩니다.
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
검색할 속성의 식별자입니다.
반품
지정된 속성의 값을 포함하는 개체입니다.
예외
요청된 속성이 캐시에 없습니다.
UI(사용자 인터페이스)가 AutomationElement 더 이상 존재하지 않습니다.
예제
다음은 이 메서드를 사용하여 캐시된 속성을 검색하는 방법을 보여줍니다.
/// <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 자동화 공급자가 속성을 지원하는 경우 속성 값이 반환됩니다. 그렇지 않으면 UI 자동화에서 지정한 기본 속성이 반환됩니다. 기본 속성에 대한 자세한 내용은 다음과 같은 AutomationElement속성 식별자 필드를 AcceleratorKeyProperty참조하세요.
GetCachedPropertyValue 는 's 캐시에서 AutomationElement지정된 속성을 검색합니다. 지정된 속성 호출 GetCurrentPropertyValue에 대한 현재 개체를 검색하려면 .
요청된 속성이 이전에 캐시되지 않은 경우 이 메서드는 예외를 throw합니다.
적용 대상
GetCachedPropertyValue(AutomationProperty, Boolean)
이 캐시에서 AutomationElement지정된 속성의 값을 검색하고 필요에 따라 기본 속성을 무시합니다.
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
검색할 속성의 식별자입니다.
- ignoreDefaultValue
- Boolean
지정된 속성이 지원되지 않는 경우 기본값을 무시할지 여부를 지정하는 값입니다.
반품
지정된 속성의 값을 포함하는 개체이거나 NotSupported 요소가 값을 ignoreDefaultValue 제공하지 않고 있는 경우입니다 true.
예외
요청된 속성이 캐시에 없습니다.
해당 UI가 AutomationElement 더 이상 존재하지 않습니다.
예제
다음 예제에서는 이 메서드를 사용하여 캐시된 속성을 검색하는 방법을 보여줍니다.
/// <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. 현재 속성을 검색하려면 .를 호출 GetCurrentPropertyValue합니다.
false 전달 ignoreDefaultValue 은 호출AutomationElement.GetCachedPropertyValue(AutomationProperty)과 동일합니다.
요소 자체에 대한 UI 자동화 공급자가 속성을 지원하는 경우 속성 값이 반환됩니다. 그렇지 않으면 ignoreDefaultValuefalseUI 자동화에서 지정한 기본 속성이 반환됩니다. 기본 속성에 대한 자세한 내용은 다음과 같은 AutomationElement속성 식별자 필드를 AcceleratorKeyProperty참조하세요.
요청된 속성이 이전에 캐시되지 않은 경우 이 메서드는 예외를 throw합니다.