using System; using System.Collections.Generic; using System.Text; namespace Utils { public static class ExtensionMethods { public static TR MapValue(this Dictionary dic, TK key, Func found) { return dic.TryGetValue(key, out var value) ? found(value) : default; } public static TR MapValue(this Dictionary dic, TK key, Func found, Func notFound) { return dic.TryGetValue(key, out var value) ? found(value) : notFound(); } public static void FilterChars(this StringBuilder sb, HashSet chars, char replace = '_') { for (var i = 0; i < sb.Length; i++) { if (chars.Contains(sb[i])) sb[i] = replace; } } } }