private void button1Filter_Click_1(object sender, EventArgs e) { if (_fullCatalog == null) { MessageBox.Show("Please, open the XML file firstly", "Oops!"); return; } IXmlParserStrategy xmlParser = null; if (radioButton1.Checked) { xmlParser = new DomXmlParser(); } else if (radioButton2.Checked) { xmlParser = new SaxXmlParser(); } else { xmlParser = new LinqToXmlParser(); } _xmlContext = new XmlParserContext(xmlParser); CD cdParams = FindFilter(); _filteredCatalog = _xmlContext.Parse(_xmlFile, cdParams); FillRichTextBox(_filteredCatalog); }
private void button4Open_Click(object sender, EventArgs e) { if (!radioButton1.Checked && !radioButton2.Checked && !radioButton3.Checked) { MessageBox.Show("Please, choose the XML parse type firstly.", "Oops!"); return; } IXmlParserStrategy xmlParser = null; if (radioButton1.Checked) { xmlParser = new DomXmlParser(); } else if (radioButton2.Checked) { xmlParser = new SaxXmlParser(); } else { xmlParser = new LinqToXmlParser(); } _xmlContext = new XmlParserContext(xmlParser); OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "XML File|*.xml"; openFileDialog.Title = "Xml file opening"; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { _xmlFile = openFileDialog.FileName; _fullCatalog = _xmlContext.Parse(_xmlFile, new CD()); FillRichTextBox(_fullCatalog); FillComboBoxes(_fullCatalog); } }
public XmlParserContext(IXmlParserStrategy strategy) { Context = strategy; }