Esempio n. 1
0
        /// <summary>
        /// Code to extract all A11yElement objects with failed results. Based on
        /// the code to display the failed results in Accessibility Insights for Windows.
        /// </summary>
        /// <param name="sa">The SelectAction that defines the context</param>
        private static List <(RuleResult, A11yElement)> ExtractFailedResults(SelectAction sa)
        {
            Guid ecId = sa.GetSelectedElementContextId().Value;
            ElementDataContext dataContext = GetDataAction.GetElementDataContext(ecId);

            List <(RuleResult, A11yElement)> list = new List <(RuleResult, A11yElement)>();

            foreach (var element in dataContext.Elements.Values)
            {
                if (element.ScanResults?.Items == null ||
                    element.ScanResults.Items.Count == 0)
                {
                    continue;
                }

                foreach (var item in element.ScanResults.Items)
                {
                    var failures =
                        from ruleResult in item.Items
                        where ruleResult.Status == ScanStatus.Fail || ruleResult.Status == ScanStatus.ScanNotSupported
                        select(ruleResult, element);

                    list.AddRange(failures);
                }
            }

            return(list);
        }