public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams) { SatifyDependencies(); ParseParameters(replacementsDictionary); if (ViewModel == null) { ViewModel = new MultiPlatformViewModel(); } foreach (var platform in platformProvider.GetSupportedPlatforms()) { ViewModel.Platforms.Add(platform); } if (ShowDialog) { if (View == null) { View = new MultiPlatformView(); View.DataContext = ViewModel; uiShell.SetOwner(View); } if (!View.ShowDialog().GetValueOrDefault()) { throw new WizardBackoutException(); } } }
protected override void Execute() { var context = new SolutionContext(solutionExplorer); context.Initialize(solutionExplorer.Solution.ActiveProject); var viewModel = new AddPlatformImplementationViewModel(); foreach (var platform in platformProvider.GetSupportedPlatforms()) { platform.IsEnabled = context.GetProjectNode(platform) == null; viewModel.Platforms.Add(platform); } if (!viewModel.Platforms.Any(x => x.IsEnabled)) { MessageBox.Show( "The available platform projects are already present in the current solution. Please select a different library or remove any of the platform projects.", "Add Platform Implementation", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } viewModel.IsSharedProjectEnabled = context.SharedProject == null; var view = new AddPlatformImplementationView(); view.DataContext = viewModel; if (dialogService.ShowDialog(view) == true) { if (context.SharedProject == null && viewModel.UseSharedProject) { context.SharedProject = solutionExplorer.Solution.UnfoldTemplate( Constants.Templates.SharedProject, context.SharedProjectName); } if (context.NuGetProject == null) { context.NuGetProject = solutionExplorer.Solution.UnfoldTemplate( Constants.Templates.NuGetPackage, context.NuGetProjectName); } context.NuGetProject.AddReference(context.SelectedProject); EnsureBuildPackagingNugetInstalled(context.SelectedProject); foreach (var selectedPlatform in viewModel.Platforms.Where(x => x.IsEnabled && x.IsSelected)) { var projectName = context.GetTargetProjectName(selectedPlatform); var project = context.GetProjectNode(projectName); if (project == null) { project = solutionExplorer.Solution.UnfoldTemplate( Constants.Templates.GetPlatformTemplate(selectedPlatform.Id), projectName); } EnsureBuildPackagingNugetInstalled(project); if (context.SharedProject != null && viewModel.UseSharedProject) { project.AddReference(context.SharedProject); } context.NuGetProject.AddReference(project); } } }