Example #1
0
        /// <summary>
        /// Locate the target element in the UIA tree
        /// </summary>
        /// <param name="parameters">The caller-provided parameters</param>
        /// <returns>The ElementContext that matches the targeting parameters</returns>
        internal static ElementContext LocateElement(CommandParameters parameters)
        {
            if (parameters.TryGetLong(CommandConstStrings.TargetProcessId, out long parameterPid))
            {
                try
                {
                    var element = A11yAutomation.ElementFromProcessId((int)parameterPid);

                    return(new ElementContext(element));
                }
                catch (Exception ex)
                {
                    throw new A11yAutomationException(string.Format(CultureInfo.InvariantCulture, DisplayStrings.ErrorFailToGetRootElementOfProcess, parameterPid, ex), ex);
                }
            }

            throw new A11yAutomationException(DisplayStrings.ErrorNoProcessIdSet);
        }
 /// <summary>
 /// Check to see if files should be retained even when no violations are found
 /// </summary>
 /// <param name="parameters">The CommandParameters object to check</param>
 /// <returns>true iff files are always retained, even if no errors exist.
 /// Retention is our default behavior unless we're explicitly told to discard</returns>
 internal static bool RetainIfNoViolations(this CommandParameters parameters)
 {
     return(!(parameters.TryGetString(CommandConstStrings.NoViolationPolicy, out string policy) &&
              policy.Equals(CommandConstStrings.Discard, StringComparison.OrdinalIgnoreCase)));
 }