Esempio n. 1
0
        private void LoadFiles(object sender, RoutedEventArgs e)
        {
            var fileDialog = new OpenFileDialog
            {
                InitialDirectory = _settingsManager.LastSearchedFolder,
                Multiselect      = true
            };

            fileDialog.ShowDialog();
            if (0 == fileDialog.FileNames.Length)
            {
                return;
            }
            _settingsManager.LastSearchedFolder = Path.GetDirectoryName(fileDialog.FileName);
            try
            {
                analysisResults = RecordParser.Parse(fileDialog.FileNames);
            } catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            dgrdAnalyticResults.DataContext = analysisResults;
            dgrdAnalyticResults.Items.Refresh();
        }
Esempio n. 2
0
        public void TestParse()
        {
            RecordParser parser = new RecordParser();
            Record       record = parser.Parse("123. abcd");

            Assert.Equal(new Record(123, "abcd"), record);
        }
Esempio n. 3
0
        /// <summary>
        /// Saves the specified type of records to the specified repository.
        /// </summary>
        /// <param name="repository">The repository to save to.</param>
        /// <param name="type">The types of records to save.</param>
        public void SaveTo(PafRepository repository, MainfileType type)
        {
            Check.IsNotNull(repository, "repository");

            RecordParser parser = RecordParserFactory.Create(type);

            if (parser != null)
            {
                foreach (MainfileInfo info in this.fileInfos.Where(fi => fi.FileType == type))
                {
                    parser.Parse(info, repository);
                }
            }
        }
Esempio n. 4
0
        public IEnumerable <DataRecord> ReadData()
        {
            this.token    = new CancellationTokenSource();
            this.readTask = Task.Run(() => this.FastReadLineTask(this.token.Token));

            var recordParser = new RecordParser(this.config.Columns);

            while (!this.eof || this.buffer.Count > 0)
            {
                if (this.buffer.TryDequeue(out DataRecord record))
                {
                    record.Parsed = recordParser.Parse(record.Source);
                    yield return(record);
                }
                else
                {
                    Thread.Sleep(50);
                }
            }
        }
Esempio n. 5
0
        public void GivenValidRecord_ShouldParseFields(string record, string[] expected)
        {
            var actual = target.Parse(record);

            Assert.Equal(expected, actual);
        }