Exemple #1
0
        /// <summary>
        /// mark all subcategories that have identical filtering
        /// </summary>
        private void CheckAndMarkConflicts()
        {
            // Can't guarantee iteration order of dict will be the same each time so need a set of elements that have been processed
            // to ensure conflicts are only checked against elements that are already checked
            // by only checking against processed elements we know we're only adding checking for collisions between each pair once
            var processedElements = new List <string>();

            foreach (KeyValuePair <string, SubcategoryNode> kvpOuter in subCategoriesDict)
            {
                foreach (string subcatName in processedElements)
                {
                    SubcategoryNode processedSubcat = subCategoriesDict[subcatName];
                    if (FilterNode.CompareFilterLists(processedSubcat.Filters, kvpOuter.Value.Filters))
                    {
                        // add conflict entry for the already entered subCategory
                        if (conflictsDict.TryGetValue(subcatName, out List <string> conflicts))
                        {
                            conflicts.Add(kvpOuter.Key);
                        }
                        else
                        {
                            conflictsDict.Add(subcatName, new List <string>()
                            {
                                kvpOuter.Key
                            });
                        }

                        // add a conflict entry for the new subcategory
                        if (conflictsDict.TryGetValue(kvpOuter.Key, out conflicts))
                        {
                            conflicts.Add(subcatName);
                        }
                        else
                        {
                            conflictsDict.Add(kvpOuter.Key, new List <string>()
                            {
                                subcatName
                            });
                        }
                    }
                }
                processedElements.Add(kvpOuter.Key);
            }
        }