public IFileViewer Create(IFile file) { var errorMessage = ""; if (_dataForgeFileCache[file] == null) { // HACK(PJ): load only once for now. Caching for open p4k most likely. try { using (var s = file.Read()) using (var r = new BinaryReader(s)) { _dataForgeFileCache[file] = new DataForgeFile(r, _messages); } } catch (Exception e) { errorMessage = $"There was an error opening {file.Name}.\r\n\r\n{e.Message}\r\n\r\n{e.StackTrace}"; _messages.Add(errorMessage); } } return(new DataForgeFileViewer(_dataForgeFileCache[file], errorMessage)); }
public DataForgeFile this[IFile file] { get { if (_currentFile == file) { return(_current); } return(null); } set { _currentFile = file; _current = value; } }
public DataForgeFileViewer(IFile file) { if (_df != null) { // HACK(PJ): load only once for now. Caching for open p4k most likely. return; } try { using (var s = file.Read()) using (var r = new BinaryReader(s)) { _df = new DataForgeFile(r); } } catch (Exception e) { ErrorMessage = $"There was an error opening {file.Name}.\r\n\r\n{e.Message}\r\n\r\n{e.StackTrace}"; } }
internal DataForgeFileViewer(DataForgeFile df, string errorMessage) { _df = df; ErrorMessage = errorMessage; }