Exemplo n.º 1
0
        public void Should_Return_Error_Msg_For_Null_GetFishList_Tank()
        {
            var sut = new XmlSaver(Config, null);

            var actual = sut.Save();

            Assert.AreEqual("XML file could not be created!", actual);
        }
Exemplo n.º 2
0
        public void Should_Return_Error_Msg_For_Fault_File_Name()
        {
            var faultConfig = new ConfigurationBuilder()
                              .AddInMemoryCollection(new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("FaultFileName", "TestTank.xml"),
            })
                              .Build();

            var sut = new XmlSaver(faultConfig, _tank);

            var actual = sut.Save();

            Assert.AreEqual("File path is not found!", actual);
        }
Exemplo n.º 3
0
        private void SaveXmlProtocolFile(string fileName = null)
        {
            if (!ValidateIndexes())
            {
                return;
            }

            if (_currentNode?.Tag is CustomType)
            {
                _customTypeEditor.Value.UpdateGrid();
            }

            if (string.IsNullOrWhiteSpace(fileName))
            {
                using (var dlg = new SaveFileDialog()
                {
                    Filter = "XML файлы|*.xml|Все файлы|*.*",
                    Title = "Сохранить протокол работы с компрессором",
                    FileName = Indexes.Name
                               //FilterIndex = 2
                })
                {
                    if (dlg.ShowDialog() == DialogResult.OK &&
                        !string.IsNullOrWhiteSpace(dlg.FileName))
                    {
                        fileName = dlg.FileName;
                    }
                }
            }
            if (!string.IsNullOrWhiteSpace(fileName))
            {
                if (XmlSaver <Indexes> .Save(Indexes, fileName))
                {
                    _hasChanges                = false;
                    _protocolFileName          = fileName;
                    toolStripStatusLabel1.Text = $"{fileName} успешно сохранен";
                }
                else
                {
                    toolStripStatusLabel1.Text = "Ошибка при сохранении протокола";
                }
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                throw new ArgumentNullException("Nie podano parametrów.");
            }

            try {
                var reader   = new CsvReader(args[0]);
                var list     = reader.Read();
                var students = new StudentsList(list).Validate();
                var fileName = "result.xml";
                var format   = "xml";

                if (args.Length >= 2)
                {
                    fileName = args[1];
                }

                if (args.Length == 3)
                {
                    format = args[2];
                }

                if (format == "xml")
                {
                    var xmlSaver = new XmlSaver <Student>(students);
                    xmlSaver.Save(fileName);
                }
                else
                {
                    throw new ArgumentOutOfRangeException("Nieznany format: " + format);
                }
            } catch (FileNotFoundException) {
                throw new FileNotFoundException("Nie znaleziono pliku: " + args[0]);
            }
        }
Exemplo n.º 5
0
 public void SaveCompressors()
 {
     ClearCompressorsValues();
     XmlSaver <List <CompressorSetting> > .Save(Compressors, FileNames.Compressors);
 }
Exemplo n.º 6
0
 public void SaveComPorts()
 {
     XmlSaver <List <ComPortSetting> > .Save(ComPortSettings, FileNames.ComPorts);
 }