コード例 #1
0
        /// <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;
            }
        }
コード例 #2
0
 private static void ShutdownContainer()
 {
     if (ApplicationServiceLocator.Container != null)
     {
         ApplicationServiceLocator.Shutdown();
     }
 }
コード例 #3
0
 private static void InitializeContainer()
 {
     if (ApplicationServiceLocator.Container == null)
     {
         ApplicationServiceLocator.InitializeAsync(new Container(), new DesktopBootstrapper()).Wait();
     }
 }
コード例 #4
0
        public static void InitialiseContainer()
        {
            if (ApplicationServiceLocator.IsInitialized)
            {
                return;
            }

            try
            {
                ApplicationServiceLocator.InitializeAsync(new Container(), new DesktopBootstrapper()).Wait();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }
コード例 #5
0
ファイル: App.xaml.cs プロジェクト: Visyn/Visyn.MsBuild
        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);
            }
        }
コード例 #6
0
 public MoviesController()
 {
     _menuService = ApplicationServiceLocator.GetService <IMovieService>();
 }
コード例 #7
0
 public static void ShutdownContainer()
 {
     ApplicationServiceLocator.Shutdown();
 }