Пример #1
0
        private void loadAllData(string directory)
        {
            int lIndexOfSlash = 0, lIndexOfdot = 0;
            string sub = "";
            ch = new checker();
            List<string> r_ports = new List<string>();
            List<string> p_ports = new List<string>();
            List<string> comps = ch.getComponents(directory);
            TextWriter tw = new StreamWriter("data.xml");
            sr = new Hashtable();

            tw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            tw.WriteLine("<root>");
            foreach (string comp in comps)
            {
                lIndexOfSlash = comp.LastIndexOf("\\");
                lIndexOfdot = comp.LastIndexOf(".");
                sub = comp.Substring(lIndexOfSlash + 1, lIndexOfdot - lIndexOfSlash - 1);

                tw.WriteLine("<component name = \"" + sub + "\">");

                p_ports = ch.p_port(comp);
                tw.WriteLine("<pr_ports>");
                foreach (string p_port in p_ports)
                {
                    tw.WriteLine("<name>" + p_port + "</name>");

                }
                r_ports = ch.r_port(comp);
                foreach (string r_port in r_ports)
                {
                    tw.WriteLine("<name>" + r_port + "</name>");
                }
                tw.WriteLine("</pr_ports>");

                tw.WriteLine("<sr_ports>");
                sr = ch.sr_port(comp);
                foreach (string sr_port in sr.Keys)
                {
                    tw.WriteLine("<name>" + sr_port + "</name>");
                }
                tw.WriteLine("</sr_ports>");

                tw.WriteLine("<data_elements>");
                foreach (string dataE in sr.Values)
                {

                    tw.WriteLine("<name>" + dataE + "</name>");
                }
                tw.WriteLine("</data_elements>");

                this.listBox_port_component.Items.Add(sub);
                this.listBox_signal_component.Items.Add(sub);
                tw.WriteLine("</component>");
            }
            tw.WriteLine("</root>");
            tw.Close();
            this.label1.Text = "Total: " + comps.Count;
            label5.Text = "Total: " + comps.Count;
        }
Пример #2
0
        private void loadAllData(string directory)
        {
            int    lIndexOfSlash = 0, lIndexOfdot = 0;
            string sub = "";

            ch = new checker();
            List <string> r_ports = new List <string>();
            List <string> p_ports = new List <string>();
            List <string> comps   = ch.getComponents(directory);
            TextWriter    tw      = new StreamWriter("data.xml");

            sr = new Hashtable();

            tw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            tw.WriteLine("<root>");
            foreach (string comp in comps)
            {
                lIndexOfSlash = comp.LastIndexOf("\\");
                lIndexOfdot   = comp.LastIndexOf(".");
                sub           = comp.Substring(lIndexOfSlash + 1, lIndexOfdot - lIndexOfSlash - 1);

                tw.WriteLine("<component name = \"" + sub + "\">");

                p_ports = ch.p_port(comp);
                tw.WriteLine("<pr_ports>");
                foreach (string p_port in p_ports)
                {
                    tw.WriteLine("<name>" + p_port + "</name>");
                }
                r_ports = ch.r_port(comp);
                foreach (string r_port in r_ports)
                {
                    tw.WriteLine("<name>" + r_port + "</name>");
                }
                tw.WriteLine("</pr_ports>");

                tw.WriteLine("<sr_ports>");
                sr = ch.sr_port(comp);
                foreach (string sr_port in sr.Keys)
                {
                    tw.WriteLine("<name>" + sr_port + "</name>");
                }
                tw.WriteLine("</sr_ports>");


                tw.WriteLine("<data_elements>");
                foreach (string dataE in sr.Values)
                {
                    tw.WriteLine("<name>" + dataE + "</name>");
                }
                tw.WriteLine("</data_elements>");


                this.listBox_port_component.Items.Add(sub);
                this.listBox_signal_component.Items.Add(sub);
                tw.WriteLine("</component>");
            }
            tw.WriteLine("</root>");
            tw.Close();
            this.label1.Text = "Total: " + comps.Count;
            label5.Text      = "Total: " + comps.Count;
        }