Пример #1
0
        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);
        }
Пример #2
0
        void ICommandHandler <CompileAndRunSingleFileCommandDefinition> .Update(Command command)
        {
            ICompiler compiler;

            if (CanCompileSingleFile(FilePath, out compiler))
            {
                command.IsEnabled = true;
                command.Tag       = compiler;
            }
            else
            {
                command.IsEnabled = false;
            }
        }
Пример #3
0
        void ICommandHandler <RunSingleFileCommandDefinition> .Update(Command command)
        {
            string outputFileName;

            if (CanRunSingleFile(FilePath, out outputFileName))
            {
                command.IsEnabled = true;
                command.Tag       = outputFileName;
            }
            else
            {
                command.IsEnabled = false;
            }
        }
Пример #4
0
        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);
        }
Пример #5
0
 Task ICommandHandler <RunSingleFileCommandDefinition> .Run(Command command)
 {
     return(RunSingleFile(command.Tag as string));
 }