public static MedlineFile Parse(string filePath) { List<Citation> citationList = null; try { using (FileStream fileStream = new FileStream(filePath, FileMode.Open)) { using (StreamReader reader = new StreamReader(fileStream)) { citationList = AddCitations(reader); } } } catch (Exception ex) { throw ex; } //catch(FileNotFoundException ex) //{ // D //} //catch (DirectoryNotFoundException ex) //{ //} //catch (PathTooLongException ex) //{ //} //catch (OutOfMemoryException ex) //{ //} //catch (SecurityException ex) //{ //} //catch (NotSupportedException ex) //{ //} MedlineFile result = new MedlineFile(filePath, citationList); return result; }
public MedlineFileViewModel(string filePath) { if (string.IsNullOrWhiteSpace(filePath)) { throw new ArgumentNullException("name"); } Name = Path.GetFileName(filePath); FullPath = Path.GetFullPath(filePath); string absolutePath = Path.GetFullPath(filePath); try { medlineFile = MedlineParser.Parse(absolutePath); Citations = new ObservableCollection<CitationViewModel>(); foreach (Citation citation in medlineFile.Citations) { CitationViewModel citationModel = new CitationViewModel(citation); Citations.Add(citationModel); } } catch(Exception ex) { throw ex; } }