/// <summary> /// Get Property value safely /// </summary> /// <param name="element"></param> /// <param name="id"></param> /// <returns></returns> private static dynamic GetPropertyValueFromCache(IUIAutomationElement element, int id) { dynamic value = null; try { dynamic temp = ShouldGetPropertyValueNoDefault(id) ? element.GetCachedPropertyValueEx(id, 1 /*true*/) : element.GetCachedPropertyValue(id); value = ConvertVariantAsNeeded(temp); } catch { value = null; } return(value); }
/// <summary> /// Get Property value safely /// </summary> /// <param name="element"></param> /// <param name="id"></param> /// <returns></returns> private static dynamic GetPropertyValueFromCache(IUIAutomationElement element, int id) { dynamic value = null; try { dynamic temp = ShouldGetPropertyValueNoDefault(id) ? element.GetCachedPropertyValueEx(id, 1 /*true*/) : element.GetCachedPropertyValue(id); value = ConvertVariantAsNeeded(temp); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception e) { e.ReportException(); value = null; } #pragma warning restore CA1031 // Do not catch general exception types return value; }