/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> #pragma warning disable VSTHRD100 // Avoid async void methods private async void Execute(object sender, EventArgs e) #pragma warning restore VSTHRD100 // Avoid async void methods { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(_package.DisposalToken); var dte = (DTE)await _package.GetServiceAsync(typeof(DTE)); if (dte == null) { throw new ArgumentNullException(nameof(dte)); } var selectedItems = dte.SelectedItems; if (selectedItems == null) { return; } foreach (SelectedItem selectedItem in selectedItems) { if (!(selectedItem.ProjectItem is ProjectItem projectItem)) { continue; } var filePath = projectItem.FileNames[0]; var unitTestClassWriter = ApplicationServiceLocator.GetService <ITestClassSetupService>(); unitTestClassWriter.SetupTestClass(filePath); break; } }
private static void ShutdownContainer() { if (ApplicationServiceLocator.Container != null) { ApplicationServiceLocator.Shutdown(); } }
private static void InitializeContainer() { if (ApplicationServiceLocator.Container == null) { ApplicationServiceLocator.InitializeAsync(new Container(), new DesktopBootstrapper()).Wait(); } }
public static void InitialiseContainer() { if (ApplicationServiceLocator.IsInitialized) { return; } try { ApplicationServiceLocator.InitializeAsync(new Container(), new DesktopBootstrapper()).Wait(); } catch (Exception ex) { Debug.WriteLine(ex.Message); } }
protected override void OnStartup(StartupEventArgs args) { ApplicationServiceLocator.Register <Dispatcher>(Dispatcher.CurrentDispatcher, true); base.OnStartup(args); // Add the event handler for handling UI thread exceptions to the event. DispatcherUnhandledException += OnDispatcherUnhandledException; CommandLine.ProcessStartupArguments(args); if (Headless) { var text = CommandLine.ExecuteCommandLine(); foreach (var line in text) { Console.WriteLine(line); } Shutdown(1); return; } else { StartupUri = new Uri("View/MainWindow.xaml", UriKind.Relative); } }
public MoviesController() { _menuService = ApplicationServiceLocator.GetService <IMovieService>(); }
public static void ShutdownContainer() { ApplicationServiceLocator.Shutdown(); }