internal bool IsMatch(System.Text.RegularExpressions.Regex mask, ManualLookupLocation ll) { if ((ll & ManualLookupLocation.SectionTitles) != 0) { if (mask.IsMatch(title)) { return(true); } } if ((ll & ManualLookupLocation.SectionBodies) != 0) { if (mask.IsMatch(body)) { return(true); } } if (subs.Where(s => s.IsMatch(mask, ll)).Any()) { return(true); } return(false); }
internal bool IsMatch(System.Text.RegularExpressions.Regex mask, ManualLookupLocation ll) { //System.Diagnostics.Debug.WriteLine("Checking {0}:\n\t{1} | {2}", this, mask, ll); if ((ll & ManualLookupLocation.ManualTitle) != 0) { if (mask.IsMatch(title)) { return(true); } } if ((ll & ManualLookupLocation.ManualAbstract) != 0) { if (mask.IsMatch(abstr)) { return(true); } } if ((ll & (ManualLookupLocation.SectionTitles | ManualLookupLocation.SectionBodies)) != 0) { if (subs.Where(s => s.IsMatch(mask, ll)).Any()) { return(true); } } return(false); }
/// <summary> /// Finds a manual by matching specific elements against a regular expression. /// </summary> /// <param name="mask"></param> /// <param name="lookupLocation">A set of flags containing elements to look up.</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">Thrown when the given regular expression is null.</exception> /// <exception cref="System.ArgumentException">Thrown when the given lookup location set does not contain any location (is 0).</exception> public IEnumerable <Manual> FindManual(Regex mask, ManualLookupLocation lookupLocation = ManualLookupLocation.ManualTitle) { if (mask == null) { throw new ArgumentNullException("mask"); } if (lookupLocation == 0) { throw new ArgumentException("There must be at least one lookup location.", "lookupLocation"); } return(mans.Values.Where(m => m.IsMatch(mask, lookupLocation))); }