Пример #1
0
        public void VerifyThatSerializeDeSerializeWorks()
        {
            var obj = CsvParser.ParseProject("testdata");

            if (!Directory.Exists(Path.GetDirectoryName(pathToXml)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(pathToXml));
            }

            XmlDeSerializer.WriteXml(obj, pathToXml);

            Assert.IsTrue(File.Exists(pathToXml));

            var obj2 = XmlDeSerializer.LoadXml(pathToXml);

            Assert.IsNotNull(obj2);
            Assert.AreEqual(2, obj2.Packages.Count);

            Assert.IsTrue(pathToXml.Equals(obj2.FileName));
            Assert.AreEqual("testdata (testoutput\\Stringtable.xml)", obj2.NodeName);

            XmlDeSerializer.WriteXml(obj2, pathToSaveXml);

            Assert.IsTrue(obj2.FileName.Equals(pathToSaveXml));
        }
Пример #2
0
        /// <summary>
        /// Execute the open command
        /// </summary>
        private void OpenCommandExecute()
        {
            // clear previous
            var collection = new ObservableCollection <Project>();

            var dlg = new CommonOpenFileDialog();

            dlg.Filters.Add(new CommonFileDialogFilter("XML file", "*.xml"));
            dlg.DefaultFileName = "Stringtable.xml";

            if (dlg.ShowDialog() == CommonFileDialogResult.Ok && File.Exists(dlg.FileName))
            {
                collection.Add(XmlDeSerializer.LoadXml(dlg.FileName));
            }

            this.Projects = collection;
        }