private void UpdateClassifiers() { var settings = Settings.Load(); var patterns = settings.Patterns ?? new RegExClassification[0]; var classifiers = patterns.Select( pattern => new { classificationType = pattern.ClassificationType.ToString(), test = RegExClassification.RegExFactory(pattern) }) .Select(temp => new Classifier { Type = temp.classificationType, Test = text => temp.test.IsMatch(text) }) .ToList(); classifiers.Add(new Classifier { Type = OutputClassificationDefinitions.BuildText, Test = t => true }); _classifiers = classifiers; }
public static Regex RegExFactory(RegExClassification pattern) { return(new Regex( pattern.RegExPattern, pattern.IgnoreCase ? RegexOptions.IgnoreCase : RegexOptions.None, TimeSpan.FromMilliseconds(250))); }