Esempio n. 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));
        }
Esempio n. 2
0
 /// <summary>
 /// Quick save a single project
 /// </summary>
 /// <param name="prj">The project to save</param>
 private static void QuickSaveProject(Project prj)
 {
     if (!string.IsNullOrWhiteSpace(prj.FileName))
     {
         XmlDeSerializer.WriteXml(prj, prj.FileName);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Execute the save as command
        /// </summary>
        private void SaveAsCommandExecute()
        {
            if (this.Projects.Count != 1)
            {
                return;
            }

            var prjct = this.Projects[0];

            var dlg = new CommonSaveFileDialog {
                DefaultFileName = "Stringtable.xml"
            };

            if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
            {
                XmlDeSerializer.WriteXml(prjct, dlg.FileName);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Execute the ok command
        /// </summary>
        private async void OkExecute()
        {
            // ask if the user wants to proceed if the selected source modifier is not nothing
            if (this.SelectedSourceAction != SourceAction.Nothing)
            {
                var dlg =
                    MessageBox.Show(
                        "You chose to modify the source. This is a unreversible action. Do you want to proceed?", "Warning",
                        MessageBoxButton.YesNo, MessageBoxImage.Exclamation);

                if (dlg != MessageBoxResult.Yes)
                {
                    return;
                }
            }

            this.isBusy            = true;
            this.IsProgressVisible = Visibility.Visible;
            Mouse.OverrideCursor   = Cursors.Wait;

            var prjct = await Task.Run(() => CsvParser.ParseProject(this.SourcePath, this.SelectedSourceAction, this.FillMissing));

            this.isBusy            = false;
            this.IsProgressVisible = Visibility.Hidden;
            Mouse.OverrideCursor   = null;

            // check for override
            if (File.Exists(this.DestinationPath))
            {
                var dlg =
                    MessageBox.Show(
                        "The selected destination file already exists. Do you want to proceed?", "Warning",
                        MessageBoxButton.YesNo, MessageBoxImage.Exclamation);

                if (dlg != MessageBoxResult.Yes)
                {
                    return;
                }
            }

            XmlDeSerializer.WriteXml(prjct, this.DestinationPath);
        }