/// <summary> /// Retrieves the value of a text attribute over the entire range. /// </summary> /// <param name="attribute">The text attribute.</param> /// <returns>The value of the attribute across the range. /// If the attribute's value varies over the range then the value is TextPattern.MixedAttributeValue</returns> public object GetAttributeValue(AutomationTextAttribute attribute) { Misc.ValidateArgumentNonNull(attribute, "attribute"); AutomationAttributeInfo ai; if (!Schema.GetAttributeInfo(attribute, out ai)) { throw new ArgumentException(SR.Get(SRID.UnsupportedAttribute)); } object obj = UiaCoreApi.TextRange_GetAttributeValue(_hTextRange, attribute.Id); if (ai.Type.IsEnum && obj is int) { // Convert ints from COM Interop to the appropriate enum type obj = Enum.ToObject(ai.Type, (int)obj); } else if (obj != AutomationElement.NotSupported && ai.ObjectConverter != null) { // Use a custom converter, if needed (eg. converts LCIDs to CultureInfo) obj = ai.ObjectConverter(obj); } return(obj); }