示例#1
0
        private void ParseXml()
        {
            Films MyFilm = Search();

            if (radioButtonDOM.Checked)
            {
                IStrategy parser = new DOM();
                res = parser.Search(MyFilm, path);
                Output(res);
            }
            else if (radioButtonSAX.Checked)
            {
                IStrategy parser = new SAX();
                res = parser.Search(MyFilm, path);
                Output(res);
            }
            else if (radioButtonLINQtoXML.Checked)
            {
                IStrategy parser = new LINQ();
                res = parser.Search(MyFilm, path);
                Output(res);
            }
            else
            {
                MessageBox.Show("select a search method", "Warninng!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#2
0
        public void fillBox()
        {
            IStrategy     p            = new LINQ();
            List <Films>  res          = p.Search(new Films(), path);
            List <string> names        = new List <string>();
            List <string> years        = new List <string>();
            List <string> ganres       = new List <string>();
            List <string> runningTimes = new List <string>();
            List <string> countries    = new List <string>();
            List <string> rates        = new List <string>();

            foreach (Films item in res)
            {
                if (!names.Contains(item.Name))
                {
                    names.Add(item.Name);
                }
                if (!years.Contains(item.Year))
                {
                    years.Add(item.Year);
                }
                if (!ganres.Contains(item.Ganre))
                {
                    ganres.Add(item.Ganre);
                }
                if (!runningTimes.Contains(item.RunningTime))
                {
                    runningTimes.Add(item.RunningTime);
                }
                if (!countries.Contains(item.Country))
                {
                    countries.Add(item.Country);
                }
                if (!rates.Contains(item.Rate))
                {
                    rates.Add(item.Rate);
                }
            }
            comboBoxName.Items.AddRange(names.ToArray());
            comboBoxName.Enabled = false;
            comboBoxYear.Items.AddRange(years.ToArray());
            comboBoxYear.Enabled = false;
            comboBoxGanre.Items.AddRange(ganres.ToArray());
            comboBoxGanre.Enabled = false;
            comboBoxRunningTime.Items.AddRange(runningTimes.ToArray());
            comboBoxRunningTime.Enabled = false;
            comboBoxCountry.Items.AddRange(countries.ToArray());
            comboBoxCountry.Enabled = false;
            comboBoxRate.Items.AddRange(rates.ToArray());
            comboBoxRate.Enabled = false;
        }