/// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> /// <param name="progress">A provider for progress updates.</param> /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); VisualStudioHelper.Initialize(this); await InitializeConfigurationAsync(); await FormatCodeFileCommand.InitializeAsync(this); await FormatAndSortCodeFileCommand.InitializeAsync(this); await BreakLongCodeLinesCommand.InitializeAsync(this); }
/// <summary>Implements the Exec method of the IDTCommandTarget interface. This is called when the command is invoked.</summary> /// <param term='commandName'>The name of the command to execute.</param> /// <param term='executeOption'>Describes how the command should be run.</param> /// <param term='varIn'>Parameters passed from the caller to the command handler.</param> /// <param term='varOut'>Parameters passed from the command handler to the caller.</param> /// <param term='handled'>Informs the caller if the command was handled or not.</param> /// <seealso class='Exec' /> public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled) { handled = false; if (executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault) { if (commandName == "EntitiesToDTOs.Connect.EntitiesToDTOs") { // Initialize VisualStudioHelper class VisualStudioHelper.Initialize(_applicationObject); // Check that a Solution is open if (VisualStudioHelper.IsSolutionOpen(_applicationObject)) { // Show the main window of EntitiesToDTOs var mainWin = new MainWindow(_applicationObject); mainWin.ShowDialog(); } handled = true; return; } } }