/// <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) { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread. await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); // Query service asynchronously from the UI thread var dte = await GetServiceAsync(typeof(DTE)) as DTE; Assumes.Present(dte); BridgeVsExtension bridge = new BridgeVsExtension(dte); // Add our command handlers for menu(commands must exist in the.vsct file) OleMenuCommandService mcs = await GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService; Assumes.Present(mcs); // Create the command for the menu item. CommandID enableCommand = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdEnableBridge); OleMenuCommand menuItemEnable = new OleMenuCommand((s, e) => bridge.Execute(CommandAction.Enable), enableCommand); menuItemEnable.BeforeQueryStatus += (s, e) => bridge.UpdateCommand(menuItemEnable, CommandAction.Enable); CommandID disableCommand = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdDisableBridge); OleMenuCommand menuItemDisable = new OleMenuCommand((s, e) => bridge.Execute(CommandAction.Disable), disableCommand); menuItemDisable.BeforeQueryStatus += (s, e) => bridge.UpdateCommand(menuItemDisable, CommandAction.Disable); CommandID gettingStarted = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdGettingStarted); OleMenuCommand menuItemGettingStarted = new OleMenuCommand((s, e) => System.Diagnostics.Process.Start("https://github.com/codingadventures/LINQBridgeVs#getting-started"), gettingStarted); CommandID sendFeedback = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdFeedback); OleMenuCommand menuItemSendFeedback = new OleMenuCommand((s, e) => System.Diagnostics.Process.Start("https://marketplace.visualstudio.com/items?itemName=codingadventures.linqbridgevs#review-details"), sendFeedback); mcs.AddCommand(menuItemEnable); mcs.AddCommand(menuItemDisable); mcs.AddCommand(menuItemGettingStarted); mcs.AddCommand(menuItemSendFeedback); bool isLinqBridgeVsConfigured = PackageConfigurator.IsBridgeVsConfigured(dte.Version); //if first time user if (isLinqBridgeVsConfigured) { return; } //Initialize Object Exporter settings PackageSettings packageSettings = null; Package: try { packageSettings = (PackageSettings)GetDialogPage(typeof(PackageSettings)); } catch { goto Package; } DialogResult messageResult = MessageBox.Show("Do you want to send anonymous error reports to LINQBridgeVs?", "LINQBridgeVs: Error Tracking", MessageBoxButtons.YesNo, MessageBoxIcon.Question); packageSettings.ErrorTrackingEnabled = messageResult == DialogResult.Yes; packageSettings.SaveSettingsToStorage(); PackageConfigurator.Install(dte.Version, dte.Edition); }
/// <inheritdoc /> /// <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> protected override void Initialize() { base.Initialize(); _dte = (DTE)GetService(typeof(SDTE)); _dteEvents = _dte.Events.DTEEvents; _dteEvents.OnStartupComplete += _dteEvents_OnStartupComplete; BridgeVsExtension bridge = new BridgeVsExtension(_dte); bool isLinqBridgeVsConfigured = PackageConfigurator.IsBridgeVsConfigured(_dte.Version); // Add our command handlers for menu(commands must exist in the.vsct file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null == mcs) { return; } // Create the command for the menu item. CommandID enableCommand = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdEnableBridge); OleMenuCommand menuItemEnable = new OleMenuCommand((s, e) => bridge.Execute(CommandAction.Enable), enableCommand); menuItemEnable.BeforeQueryStatus += (s, e) => bridge.UpdateCommand(menuItemEnable, CommandAction.Enable); CommandID disableCommand = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdDisableBridge); OleMenuCommand menuItemDisable = new OleMenuCommand((s, e) => bridge.Execute(CommandAction.Disable), disableCommand); menuItemDisable.BeforeQueryStatus += (s, e) => bridge.UpdateCommand(menuItemDisable, CommandAction.Disable); CommandID gettingStarted = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdGettingStarted); OleMenuCommand menuItemGettingStarted = new OleMenuCommand((s, e) => System.Diagnostics.Process.Start("https://github.com/codingadventures/LINQBridgeVs#getting-started"), gettingStarted); CommandID sendFeedback = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdFeedback); OleMenuCommand menuItemSendFeedback = new OleMenuCommand((s, e) => System.Diagnostics.Process.Start("https://github.com/codingadventures/LINQBridgeVs/issues"), sendFeedback); mcs.AddCommand(menuItemEnable); mcs.AddCommand(menuItemDisable); mcs.AddCommand(menuItemGettingStarted); mcs.AddCommand(menuItemSendFeedback); //Initialize Object Exporter settings _packageSettings = (PackageSettings)GetDialogPage(typeof(PackageSettings)); try { //if first time user if (isLinqBridgeVsConfigured) { return; } if (!IsElevated) { // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (Application.ResourceAssembly == null) { // ReSharper disable once HeuristicUnreachableCode Application.ResourceAssembly = typeof(Welcome).Assembly; } _welcomePage = new Welcome(_dte); } else { _installationResult = PackageConfigurator.Install(_dte.Version, _dte.Edition); } } catch (Exception e) { _error = new Error(); _error.Body = $"{e.Message} %0A {e.StackTrace}"; _error.Title = "Error during installation. 1.4.6"; Exception innerException = e.InnerException; while (innerException != null) { _error.Body += $"%0A {innerException.Message} {innerException.StackTrace}"; innerException = innerException.InnerException; } _error.Body = _error.Body.Replace(Environment.NewLine, "%0A"); } }
/// <inheritdoc /> /// <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> protected override void Initialize() { base.Initialize(); _dte = (DTE)GetService(typeof(SDTE)); _dteEvents = _dte.Events.DTEEvents; _dteEvents.OnStartupComplete += _dteEvents_OnStartupComplete; BridgeVsExtension bridge = new BridgeVsExtension(_dte); bool isLinqBridgeVsConfigured = PackageConfigurator.IsBridgeVsConfigured(_dte.Version); // Add our command handlers for menu(commands must exist in the.vsct file) OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (null == mcs) { return; } // Create the command for the menu item. CommandID enableCommand = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdEnableBridge); OleMenuCommand menuItemEnable = new OleMenuCommand((s, e) => bridge.Execute(CommandAction.Enable), enableCommand); menuItemEnable.BeforeQueryStatus += (s, e) => bridge.UpdateCommand(menuItemEnable, CommandAction.Enable); CommandID disableCommand = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdDisableBridge); OleMenuCommand menuItemDisable = new OleMenuCommand((s, e) => bridge.Execute(CommandAction.Disable), disableCommand); menuItemDisable.BeforeQueryStatus += (s, e) => bridge.UpdateCommand(menuItemDisable, CommandAction.Disable); CommandID gettingStarted = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdGettingStarted); OleMenuCommand menuItemGettingStarted = new OleMenuCommand((s, e) => System.Diagnostics.Process.Start("https://github.com/codingadventures/LINQBridgeVs#getting-started"), gettingStarted); CommandID sendFeedback = new CommandID(GuidList.GuidBridgeVsExtensionCmdSet, (int)PkgCmdIdList.CmdIdFeedback); OleMenuCommand menuItemSendFeedback = new OleMenuCommand((s, e) => System.Diagnostics.Process.Start("https://github.com/codingadventures/LINQBridgeVs/issues"), sendFeedback); mcs.AddCommand(menuItemEnable); mcs.AddCommand(menuItemDisable); mcs.AddCommand(menuItemGettingStarted); mcs.AddCommand(menuItemSendFeedback); try { Log.Configure("LINQBridgeVs", "Extensions"); //if first time user if (isLinqBridgeVsConfigured) { return; } if (!IsElevated) { // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (Application.ResourceAssembly == null) { // ReSharper disable once HeuristicUnreachableCode Application.ResourceAssembly = typeof(Welcome).Assembly; } _welcomePage = new Welcome(_dte); } else { _installationResult = PackageConfigurator.Install(_dte.Version, _dte.Edition); } } catch (Exception e) { Log.Write(e, "Initialize Error..."); MessageBox.Show("LINQBridgeVs wasn't successfully configured. Please restart Visual Studio"); } }