public void TestToString() { var filter = new OrFilter(new[] { new SubstringFilter("foo", true) }); filter.ToString().Should().Be("message.Contains(foo, InvariantCultureIgnoreCase)"); filter = new OrFilter(new ILogEntryFilter[] { new SubstringFilter("foo", true), new LevelFilter(LevelFlags.Info) }); filter.ToString().Should().Be("message.Contains(foo, InvariantCultureIgnoreCase) || level == Info"); }
private void wrapIntoAnySubfiltersToolStripMenuItem_Click(object sender, EventArgs e) { if (FilterTree.Nodes.Count == 0) { return; } TreeNode selected_node = FilterTree.SelectedNode; if (selected_node == null) { return; } OrFilter fl = new OrFilter(); TreeNode or_node = new TreeNode() { Text = fl.ToString(), Tag = fl }; // check if the node is the root if (selected_node.Parent == null) { FilterTree.Nodes.Clear(); FilterTree.Nodes.Add(or_node); SearchFilter = fl; } else { TreeNode pt = selected_node.Parent; pt.Nodes.Insert(pt.Nodes.IndexOf(selected_node), or_node); pt.Nodes.Remove(selected_node); if (pt.Tag is OrFilter) { ((OrFilter)pt.Tag).Filters.Add(fl); ((OrFilter)pt.Tag).Filters.Remove((BaseFilter)selected_node.Tag); } else if (pt.Tag is AndFilter) { ((AndFilter)pt.Tag).Filters.Add(fl); ((AndFilter)pt.Tag).Filters.Remove((BaseFilter)selected_node.Tag); } } fl.Filters.Add((BaseFilter)selected_node.Tag); or_node.Nodes.Add(selected_node); FilterTree.SelectedNode = selected_node; ShowFilterProperties((BaseFilter)selected_node.Tag); }