コード例 #1
0
 public StartupProjectSwitcher(DropdownService dropdownService, DTE dte, IVsFileChangeEx fileChangeService, SwitchStartupProjectPackage.ActivityLogger logger)
 {
     logger.LogInfo("Entering constructor of StartupProjectSwitcher");
     this.dropdownService = dropdownService;
     dropdownService.OnListItemSelected      = _ChangeStartupProject;
     dropdownService.OnConfigurationSelected = _ShowMsgOpenSolution;
     this.dte = dte;
     this.fileChangeService = fileChangeService;
     this.logger            = logger;
 }
コード例 #2
0
        /// <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 initilaization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Logger = new ActivityLogger(this);
            Logger.LogInfo("Entering initializer for: {0}", this.ToString());
            base.Initialize();

            // Add our command handlers for menu (commands must exist in the .vsct file)
            var mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null == mcs)
            {
                Logger.LogInfo("Could not get OleMenuCommandService");
                return;
            }
            var dropdownService = new DropdownService(mcs);

            // Get VS Automation object
            var dte = (EnvDTE.DTE)GetGlobalService(typeof(EnvDTE.DTE));

            // Get solution
            solution = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution)) as IVsSolution2;
            if (solution != null)
            {
                // Register for solution events
                solution.AdviseSolutionEvents(this, out solutionEventsCookie);
            }

            // Get selection monitor
            ms = ServiceProvider.GlobalProvider.GetService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;
            if (ms != null)
            {
                // Remember debugging UI context cookie for later
                ms.GetCmdUIContextCookie(VSConstants.UICONTEXT.Debugging_guid, out debuggingCookie);
                // Register for selection events
                ms.AdviseSelectionEvents(this, out selectionEventsCookie);
            }

            var fileChangeService = ServiceProvider.GlobalProvider.GetService(typeof(SVsFileChangeEx)) as IVsFileChangeEx;

            switcher = new StartupProjectSwitcher(dropdownService, dte, fileChangeService, Logger);
        }