private bool ProcessFile(string file, IMonsterConverter input, IMonsterConverter output, string outputDir) { bool result = false; try { if (input.ReadMonster(file, out Monster monster)) { if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } output.WriteMonster(outputDir, ref monster); result = true; } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"Error pasring {file}. Exception {ex.Message}"); result = false; } return(result); }
private Tuple <ConvertResult, ConvertResult> ProcessFile(string file, IMonsterConverter input, IMonsterConverter output, string outputDir) { ConvertResult readResult = new ConvertResult("unknown", ConvertError.Error, "Unknown error occured"); ConvertResult writeResult = new ConvertResult("unknown", ConvertError.Error, "Unknown error occured"); // The ReadMonster and Write methods processors should really do their best to catch and return meaningful errors try { readResult = input.ReadMonster(file, out Monster monster); if (readResult.Code != ConvertError.Error) { if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } writeResult = output.WriteMonster(outputDir, ref monster); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"Error pasring {file}. Exception {ex.Message}"); } return(new(readResult, writeResult)); }