private FileModelEntry <Project> AddProjectEntry(string projectDirectory, FileModelEntry <Project> currentEntry) { if (currentEntry == null) { currentEntry = new FileModelEntry <Project>(); } else if (!File.Exists(Path.Combine(projectDirectory, Project.FileName))) { // project was deleted currentEntry.Reset(); return(currentEntry); } if (currentEntry.IsInvalid) { Project project; if (!ProjectReader.TryGetProject(projectDirectory, out project, currentEntry.Diagnostics)) { currentEntry.Reset(); } else { currentEntry.Model = project; currentEntry.FilePath = project.ProjectFilePath; currentEntry.UpdateLastWriteTimeUtc(); } } return(currentEntry); }
private FileModelEntry <LockFile> AddLockFileEntry(string projectDirectory, FileModelEntry <LockFile> currentEntry) { if (currentEntry == null) { currentEntry = new FileModelEntry <LockFile>(); } if (currentEntry.IsInvalid) { currentEntry.Reset(); if (!File.Exists(Path.Combine(projectDirectory, LockFile.FileName))) { return(currentEntry); } else { currentEntry.FilePath = Path.Combine(projectDirectory, LockFile.FileName); currentEntry.Model = LockFileReader.Read(currentEntry.FilePath); currentEntry.UpdateLastWriteTimeUtc(); } } return(currentEntry); }
private FileModelEntry <LockFile> AddLockFileEntry(string projectDirectory, FileModelEntry <LockFile> currentEntry) { if (currentEntry == null) { currentEntry = new FileModelEntry <LockFile>(); } if (currentEntry.IsInvalid) { currentEntry.Reset(); if (!File.Exists(Path.Combine(projectDirectory, LockFile.FileName))) { return(currentEntry); } else { currentEntry.FilePath = Path.Combine(projectDirectory, LockFile.FileName); using (var fs = ResilientFileStreamOpener.OpenFile(currentEntry.FilePath, retry: 2)) { try { currentEntry.Model = LockFileReader.Read(currentEntry.FilePath, fs); currentEntry.UpdateLastWriteTimeUtc(); } catch (FileFormatException ex) { throw ex.WithFilePath(currentEntry.FilePath); } catch (Exception ex) { throw FileFormatException.Create(ex, currentEntry.FilePath); } } } } return(currentEntry); }