private void GenerateFilterEntries(List <IFilterLine> lineList) { FilterEntries.Clear(); FilterEntry lastDataEntry = new FilterEntry(); FilterEntry lastCommentEntry = new FilterEntry(); FilterConstants.FilterEntryType entryType = FilterConstants.FilterEntryType.Unknown; foreach (var line in lineList) { if (!string.IsNullOrEmpty(line.Ident)) { entryType = FilterConstants.FilterEntryType.Content; if (line.Ident == "Show" || line.Ident == "Hide") { lastDataEntry = FilterEntry.CreateDataEntry(line); FilterEntries.Add(lastDataEntry); } else { lastDataEntry.Content.Add(line); } } else if (line.Comment != string.Empty) { if (entryType != FilterConstants.FilterEntryType.Comment) { lastCommentEntry = FilterEntry.CreateCommentEntry(line); entryType = FilterConstants.FilterEntryType.Comment; FilterEntries.Add(lastCommentEntry); } else { lastCommentEntry.Content.AddComment(line); } entryType = FilterConstants.FilterEntryType.Comment; } else if (line.Comment == string.Empty) { if (entryType == FilterConstants.FilterEntryType.Filler) { continue; } else { FilterEntries.Add(FilterEntry.CreateFillerEntry()); entryType = FilterConstants.FilterEntryType.Filler; } } } }
public List <FilterEntry> Execute(ExoFilter exoFilter) { List <FilterEntry> results = new List <FilterEntry>(); ProcessTreeStep(exoFilter.RootEntry); // DO WORK; void ProcessTreeStep(ExoBlock cursor) { foreach (var readChild in cursor.Scopes) { if (readChild.Commands.Count > 0) { DoWorkOnReadChild(readChild); } if (readChild.Scopes.Count > 0) { ProcessTreeStep(readChild); } } } void DoWorkOnReadChild(ExoBlock readChild) { var entry = FilterEntry.CreateDataEntry("Show"); foreach (var comm in readChild.ResolveAndSerialize()) { var line = comm.ToFilterLine(); entry.Content.Add(line); } results.Add(entry); } return(results); }