public static (GetRule, PathExpander) Parse(IDictionary <string, RuleDefinition> rules, GetRuleParser parserResolver) { var tree = new RadixTree <IRule>(rules.ToDictionary(x => x.Key.ToLower(), x => parserResolver(x.Value.Format).Parse(x.Value.Payload))); Option <IRule> RulesRepository(ConfigurationPath path) => tree.TryGetValue(path, out var rule) ? Option <IRule> .Some(rule) : Option <IRule> .None; IEnumerable <ConfigurationPath> PathExpander(ConfigurationPath path) { if (!path.IsScan) { return new[] { path } } ; var keys = path == ConfigurationPath.FullScan ? tree.Keys : tree.ListPrefix($"{path.Folder}/").Select(c => c.key); return(keys.Select(ConfigurationPath.New).Where(x => !x.IsHidden(path.Folder))); } return(RulesRepository, PathExpander); } }