public bool ProcessFilters(ref string aLine) { bool propagateLine = false; // if (aLine.Length > 0) { int matchCount = 0; int filterCount = Count; // First phase: check for filter matches for (int i = 0; i < filterCount; i++) { AsyncTextReaderFilter filter = this[i]; // bool matchedFilter = filter.Matches(aLine); if (matchedFilter) { ++matchCount; } } // Second phase: check for overall match against combined // criteria. propagateLine = (filterCount == 0); // Default to true when no filters switch (CombinationType) { case TCombinationType.ECombinationTypeOR: propagateLine = (matchCount > 0); break; case TCombinationType.ECombinationTypeAND: propagateLine = (matchCount == filterCount); break; case TCombinationType.ECombinationTypeNOT: propagateLine = (matchCount == 0); break; default: case TCombinationType.ECombinationTypeUndefined: break; } // Third phase: process filter if (propagateLine) { for (int i = 0; i < filterCount; i++) { AsyncTextReaderFilter filter = this[i]; filter.Process(ref aLine); } } } return(propagateLine); }
public void AddFilter(AsyncTextReaderFilter aFilter) { iFilters.Add(aFilter); }
public void Remove(AsyncTextReaderFilter aFilter) { iFilters.Remove(aFilter); }