Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            FormData data = new FormData();
            data.Choose = ckbChoose.Checked;
            data.Path = txtPath.Text;
            data.Projects = new List<string>();
            foreach (string item in cboProjects.Items)
            {
                data.Projects.Add(item);
            }
            data.SelectedProject = cboProjects.SelectedIndex;
            serialize(data);

            FormData data1 = new FormData();
            data1.Choose = false;
            data1.Path = "Test Path";
            data1.Projects = new List<string>();
            for(int i = 0; i < 10; i++)
            {
                String item = "Project_" + i;
                data1.Projects.Add(item);
            }
            data1.SelectedProject = 5;
            List<FormData> list = new List<FormData>();
            list.Add(data);
            list.Add(data1);

            serialize(list);

            PlatformDevices test = new PlatformDevices();
            test.Android = new List<string>();
            test.Android.Add("D1");
            test.Android.Add("D2");
            test.Android.Add("D3");
            test.Android.Add("D4");
            test.iOS = new List<string>();
            test.iOS.Add("D11");
            test.iOS.Add("D12");
            test.iOS.Add("D13");
            test.iOS.Add("D14");
            test.Web = new List<string>();
            test.Web.Add("D21");
            test.Web.Add("D22");
            test.Web.Add("D23");
            test.Web.Add("D24");
            XmlSerializer serial = new XmlSerializer(typeof(PlatformDevices),
                new XmlRootAttribute("PlatformDevices"));
            using (TextWriter writer = new StreamWriter(@"C:\Temp\.device_test.h9config"))
            {
                serial.Serialize(writer, test);
            }
        }
Exemple #2
0
        private void serialize(FormData data)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(FormData));
            using (TextWriter writer = new StreamWriter(@"C:\Temp\.project.xml"))
            {
                serializer.Serialize(writer, data);
            }

            //FileAttributes attributes = File.GetAttributes(@"C:\Temp\.project.xml");
            //attributes = attributes | FileAttributes.Hidden;
            //File.SetAttributes(@"C:\Temp\.project.xml", attributes);
        }