async Task ICommandHandler <CompileAndRunSingleFileCommandDefinition> .Run(Command command) { // backup original content var originalContent = await _fileManager.ReadToEnd(FilePath); // write new content await _fileManager.Write(FilePath, GetContent()); // compile var compiler = command.Tag as ICompiler; if (!await CompileSingleFile(compiler, FilePath)) { return; } // rollback original content await _fileManager.Write(FilePath, originalContent); // run string outputFilePath; if (!CanRunSingleFile(FilePath, out outputFilePath)) { return; } await RunSingleFile(outputFilePath); }
void ICommandHandler <CompileAndRunSingleFileCommandDefinition> .Update(Command command) { ICompiler compiler; if (CanCompileSingleFile(FilePath, out compiler)) { command.IsEnabled = true; command.Tag = compiler; } else { command.IsEnabled = false; } }
void ICommandHandler <RunSingleFileCommandDefinition> .Update(Command command) { string outputFileName; if (CanRunSingleFile(FilePath, out outputFileName)) { command.IsEnabled = true; command.Tag = outputFileName; } else { command.IsEnabled = false; } }
async Task ICommandHandler <CompileSingleFileCommandDefinition> .Run(Command command) { // backup original content var originalContent = await _fileManager.ReadToEnd(FilePath); // write new content await _fileManager.Write(FilePath, GetContent()); // compile var compiler = command.Tag as ICompiler; await CompileSingleFile(compiler, FilePath); // rollback original content await _fileManager.Write(FilePath, originalContent); }
Task ICommandHandler <RunSingleFileCommandDefinition> .Run(Command command) { return(RunSingleFile(command.Tag as string)); }