System.Windows.Automation.Text.TextPatternRange.FindAttribute C# (CSharp) Method

FindAttribute() public method

public FindAttribute ( AutomationTextAttribute attribute, object value, bool backward ) : TextPatternRange
attribute AutomationTextAttribute
value object
backward bool
return TextPatternRange
        public TextPatternRange FindAttribute(AutomationTextAttribute attribute, object value, bool backward)
        {
            Utility.ValidateArgumentNonNull(attribute, "attribute");
            Utility.ValidateArgumentNonNull(value, "value");
            if ((attribute == TextPattern.CultureAttribute) && (value is CultureInfo))
            {
                value = ((CultureInfo)value).LCID;
            }
            try
            {
                return TextPatternRange.Wrap(
                    this._range.FindAttribute(attribute.Id, value, Utility.ConvertToInt(backward)), this._pattern);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                Exception newEx; if (Utility.ConvertException(e, out newEx)) { throw newEx; } else { throw; }
            }
        }

Usage Example

Ejemplo n.º 1
0
        //---------------------------------------------------------------------------
        // Wrapper for TextPatternRange.FindAttribute Method
        //---------------------------------------------------------------------------
        internal void Range_FindAttribute(TextPatternRange callingRange, ref TextPatternRange targetRange, AutomationTextAttribute attrib, object val, bool backward, Type expectedException, CheckType checkType)
        {
            string call = "";
            if (attrib != null)
                call = "TextPatternRange.FindAttribute(" + Helpers.GetProgrammaticName(attrib) + ", " + (val == null ? "NULL" : val.ToString()) + ", " + backward + ")";
            else
                call = "TextPatternRange.FindAttribute(NULL," + (val == null ? "NULL" : val.ToString()) + ", " + backward + ")";
            Comment("---Calling " + call);

            if (callingRange == null)
                throw new ArgumentNullException(call + " requires non-NULL TextPatterncallingRange");

            try
            {
                targetRange = callingRange.FindAttribute(attrib, val, backward);
            }
            catch (Exception actualException)
            {
                if (Library.IsCriticalException(actualException))
                    throw;

                TestException(expectedException, actualException, call, checkType);
                return;
            }
            TestNoExceptionQuiet(expectedException, call, checkType);
        }