public void SetGlobalFilterXml(XElement element) { CoverageFilter filter = this.Filter; try { this.Filter = CoverageFilter.FromXml(element.Element("filter").Elements().First()); Dictionary <string, XElement> itemElements = new Dictionary <string, XElement>(); foreach (XElement itemElement in element.Element("children").Elements("item")) { itemElements[itemElement.Attribute("name").Value] = itemElement; } foreach (CoverageItem item in this.items) { if (itemElements.ContainsKey(item.Name)) { item.SetGlobalFilterXml(itemElements[item.Name]); } else { item.Filter = null; } } } catch (Exception) { this.Filter = filter; throw; } }
private void buttonOK_Click(object sender, EventArgs e) { string oldFilter = item.GetFilterXmlDocument().ToString(); try { item.Filter = CoverageFilter.FromXml(XDocument.Load(new StringReader(textBoxFilter.Text))); this.DialogResult = DialogResult.OK; Close(); } catch (Exception ex) { item.Filter = CoverageFilter.FromXml(XDocument.Load(new StringReader(oldFilter))); MessageBox.Show(ex.Message); } }
public void SetFilterXmlDocument(XDocument document) { this.Filter = CoverageFilter.FromXml(document); }