/// <summary> /// Executes the generation. /// </summary> /// <param name="model">The model of the crypto task.</param> public async void Execute(ICryptoCodeGenerationTaskModel model) { BeforeRunningHandler(model); var project = ProjectHelpers.GetProjectOfSelectedItem(); if (project == null) { return; } var folder = ProjectHelpers.GetFolderOfSelectedItem(); var file = new FileInfo(Path.Combine(folder, model.FileName)); if (file.Exists) { OnFileAlreadyExists(file); } else { using (var template = GetBaseTemplate(model)) { if (template == null) { return; } var te = new SimpleTemplateEngine(template); ApplyTemplate(te, model, project, file); using (var codeGenerator = new SimpleFileWriter(file)) { await codeGenerator.WriteFileAsync(te.GetResult()); } } BeforeOpeningFile(); ProjectHelpers.AddFileToSelectedItem(project, file); ProjectHelpers.OpenFile(file); } }