Beispiel #1
0
        public ICalculator[] Filter(string[] terms, CalculatorFilterTarget target, bool matchCase, bool matchWholeString, MultipleFilterMatch multipleFilterMatch)
        {
            var search         = new FunctionInfoSearch(matchCase, matchWholeString, multipleFilterMatch);
            var allCalculators = this.repository.GetAll();

            var nonEmptyTerms = terms == null ? new string[0] : terms.Where(i => !string.IsNullOrWhiteSpace(i)).ToArray();

            var selectedCalculators = nonEmptyTerms.Length == 0 ? allCalculators : allCalculators.Where(i => search.IsMatch(i.Module.Function.FunctionInfo, nonEmptyTerms, CalculatorFilterTarget.All));

            return(selectedCalculators
                   .OrderBy(i => i.Module.Function.FunctionInfo.Name)
                   .ToArray());
        }
Beispiel #2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="matchCase">True to match the case of the property and the search term, false otherwise.</param>
 /// <param name="matchWholeString">True to have the match succeed only if the entire word is matched, false otherwise.</param>
 /// <param name="multipleFilterMatch">How to combine the filter results.</param>
 public FunctionInfoSearch(bool matchCase = false, bool matchWholeString = false, MultipleFilterMatch multipleFilterMatch = MultipleFilterMatch.And)
 {
     this.MatchCase           = matchCase;
     this.MatchWholeString    = matchWholeString;
     this.MultipleFilterMatch = multipleFilterMatch;
 }