static void RunTemplateActions (ProcessedTemplateResult templateResult) { foreach (string action in templateResult.Actions) { IdeApp.Workbench.OpenDocument (Path.Combine (templateResult.ProjectBasePath, action), project: null); } }
static async Task<bool> OpenCreatedSolution (ProcessedTemplateResult templateResult) { if (await IdeApp.Workspace.OpenWorkspaceItem (templateResult.SolutionFileName)) { RunTemplateActions (templateResult); return true; } return false; }
static IAsyncOperation OpenCreatedSolution (ProcessedTemplateResult templateResult) { IAsyncOperation asyncOperation = IdeApp.Workspace.OpenWorkspaceItem (templateResult.SolutionFileName); asyncOperation.Completed += delegate { if (asyncOperation.Success) { RunTemplateActions (templateResult); } }; return asyncOperation; }
bool CreateProject () { if (!projectConfiguration.IsValid ()) { MessageService.ShowError (projectConfiguration.GetErrorMessage ()); return false; } if (ParentFolder != null && ParentFolder.ParentSolution.FindProjectByName (projectConfiguration.ProjectName) != null) { MessageService.ShowError (GettextCatalog.GetString ("A Project with that name is already in your Project Space")); return false; } if (ParentWorkspace != null && SolutionAlreadyExistsInParentWorkspace ()) { MessageService.ShowError (GettextCatalog.GetString ("A solution with that filename is already in your workspace")); return false; } SolutionTemplate template = GetTemplateForProcessing (); if (ProjectNameIsLanguageKeyword (template.Language, projectConfiguration.ProjectName)) { MessageService.ShowError (GettextCatalog.GetString ("Illegal project name.\nName cannot contain a language keyword.")); return false; } ProcessedTemplateResult result = null; try { if (Directory.Exists (projectConfiguration.ProjectLocation)) { var question = GettextCatalog.GetString ("Directory {0} already exists.\nDo you want to continue creating the project?", projectConfiguration.ProjectLocation); var btn = MessageService.AskQuestion (question, AlertButton.No, AlertButton.Yes); if (btn != AlertButton.Yes) return false; } Directory.CreateDirectory (projectConfiguration.ProjectLocation); } catch (IOException) { MessageService.ShowError (GettextCatalog.GetString ("Could not create directory {0}. File already exists.", projectConfiguration.ProjectLocation)); return false; } catch (UnauthorizedAccessException) { MessageService.ShowError (GettextCatalog.GetString ("You do not have permission to create to {0}", projectConfiguration.ProjectLocation)); return false; } DisposeExistingNewItems (); try { result = IdeApp.Services.TemplatingService.ProcessTemplate (template, projectConfiguration, ParentFolder); if (!result.WorkspaceItems.Any ()) return false; } catch (UserException ex) { MessageService.ShowError (ex.Message, ex.Details); return false; } catch (Exception ex) { MessageService.ShowError (GettextCatalog.GetString ("The project could not be created"), ex); return false; } processedTemplate = result; return true; }
static void RunTemplateActions (ProcessedTemplateResult templateResult) { const string gettingStartedHint = "getting-started://"; foreach (string action in templateResult.Actions) { // handle url schemed actions like opening the getting started page (if any) if (action.StartsWith (gettingStartedHint, StringComparison.OrdinalIgnoreCase)) { var items = templateResult.WorkspaceItems.ToList (); if (items.OfType<Solution> ().Any ()) { // this is a solution that's been instantiated, lets just look for the first project var p = IdeApp.Workspace.GetAllProjects ().FirstOrDefault (); if (p != null) { GettingStarted.GettingStarted.ShowGettingStarted (p, action.Substring (gettingStartedHint.Length)); } continue; } } var fileName = Path.Combine (templateResult.ProjectBasePath, action); if (File.Exists (fileName)) { IdeApp.Workbench.OpenDocument (fileName, project: null); } } }