Example #1
0
        public static void DeleteRule(Rule rule, RequestFilteringSection section)
        {
            if (rule == null)
            {
                return;
            }

            FilteringRuleCollection collection = section.FilteringRules;

            // To utilize the remove functionality we must pull the element directly from the collection
            rule = collection.FirstOrDefault(r => r.Name.Equals(rule.Name));

            if (rule != null)
            {
                try {
                    collection.Remove(rule);
                }
                catch (FileLoadException e) {
                    throw new LockedException(section.SectionPath, e);
                }
                catch (DirectoryNotFoundException e) {
                    throw new ConfigScopeNotFoundException(e);
                }
            }
        }