public bool Matches(IGetSearchArea searchObject) { switch (Op) { default: case Operator.Invalid: // should not happen when parsing is correct. return(false); case Operator.And: if (Operands.Count == 0) { return(true); // should not every happen gotta return something... } foreach (var item in Operands) { var value = item.Matches(searchObject); if (!value) { return(IsNegated ? true : false); } } return(IsNegated ? false : true); case Operator.Or: if (Operands.Count == 0) { return(true); // should not every happen gotta return something... } foreach (var item in Operands) { var value = item.Matches(searchObject); if (value) { return(IsNegated ? false : true); } } return(IsNegated ? true : false); } }
public bool Matches(IGetSearchArea searchObject) { IList <string> inputList = searchObject.GetSearchArea(SearchArea); // might be just one string, like title:apple or might be everything like brown int index; switch (Type) { // input="mars attacks" searchfor="MARS" --> found // input="" searchFor="MARS" --> not found // input="mars attack" searchFor="" --> found // input="" searchFor="" --> found default: case SearchType.StringSearch: { if (string.IsNullOrEmpty(SearchFor)) { return(true); // must return something... } else { // if any any item matches, return true/false based on isNegated foreach (var item in inputList) { index = item.IndexOf(SearchFor, StringComparison.CurrentCultureIgnoreCase); if (index >= 0) { return(IsNegated ? false : true); } } } // Didn't find it. Return false normally, but true if isnegated. return(IsNegated ? true : false); } } }