Example #1
0
        public SolutionService([Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            _vsSolution1 = serviceProvider.GetService <SVsSolution, IVsSolution>();
            _vsSolution2 = serviceProvider.GetService <SVsSolution, IVsSolution2>();
            _vsSolution4 = serviceProvider.GetService <SVsSolution, IVsSolution4>();

            _vsImageService2 = serviceProvider.GetService <SVsImageService, IVsImageService2>();

            _vsSolution1.AdviseSolutionEvents(this, out _solutionEvents1Cookie);
            _vsSolution1.AdviseSolutionEvents(this, out _solutionEvents4Cookie);
        }
Example #2
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited.
        /// </summary>
        protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            IVsSolution solution = (IVsSolution)GetService(typeof(SVsSolution));

            ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(this, out solutionCookie));

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

            if (null != mcs)
            {
                // Create the command for the menu item.
                CommandID   menuCommandID = new CommandID(GuidList.guidLocalHistoryCmdSet, (int)PkgCmdIDList.cmdidLocalHistoryMenuItem);
                MenuCommand menuItem      = new MenuCommand(ProjectItemContextMenuHandler, menuCommandID);
                mcs.AddCommand(menuItem);

                // Create the command for the tool window
                CommandID   toolwndCommandID = new CommandID(GuidList.guidLocalHistoryCmdSet, (int)PkgCmdIDList.cmdidLocalHistoryWindow);
                MenuCommand menuToolWin      = new MenuCommand(ToolWindowMenuItemHandler, toolwndCommandID);
                mcs.AddCommand(menuToolWin);
            }
        }
Example #3
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 initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            AppDomain.CurrentDomain.UnhandledException += (sender, e) => Helpers.LogException(e.ExceptionObject as Exception);

            solutionService = (IVsSolution)GetService(typeof(SVsSolution));
            solutionService.AdviseSolutionEvents(this, out var cookie);

            var tpdService = (IVsTrackProjectDocuments2)GetService(typeof(SVsTrackProjectDocuments));

            tpdService.AdviseTrackProjectDocumentsEvents(this, out var tpdCookie);

            UiShell = (IVsUIShell)GetService(typeof(SVsUIShell));

            InitializeOptionsStorage();

            runningDocumentTable = GetService(typeof(SVsRunningDocumentTable)) as IVsRunningDocumentTable;
            runningDocumentTable.AdviseRunningDocTableEvents(this, out var rdtCookie);

            shellOpenDocument = GetService(typeof(SVsUIShellOpenDocument)) as IVsUIShellOpenDocument;

            InitializeMenu();
            InitializeCommands();

            var componentModel = (IComponentModel)GetService(typeof(SComponentModel));
            var editorAdaptersFactoryService = componentModel.GetService <IVsEditorAdaptersFactoryService>();
            var textManager = (IVsTextManager)GetService(typeof(SVsTextManager));

            BookmarksManager.InitializeAfterPackageInitialization(editorAdaptersFactoryService, textManager);
        }
Example #4
0
        public SolutionEventsListener(IServiceProvider serviceProvider)
        {
            InitNullEvents();

            Solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
            Solution?.AdviseSolutionEvents(this, out SolutionEventsCookie);
        }
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation

        /// <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()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            // listen for solution events
            _solution = (IVsSolution)GetService(typeof(SVsSolution));
            ErrorHandler.ThrowOnFailure(_solution.AdviseSolutionEvents(this, out _solutionCookie));

            _dte = (DTE)GetService(typeof(SDTE));
            var events = _dte.Events;

            _buildEvents = events.BuildEvents;

            if (_errorListProvider == null)
            {
                _errorListProvider = new ErrorListProvider(this);
            }

            Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
            {
                Options = (ShowMissingOptions)GetDialogPage(typeof(ShowMissingOptions));
            }), DispatcherPriority.ApplicationIdle, null);

            _buildEvents.OnBuildProjConfigBegin += BuildEventsOnOnBuildProjConfigBegin;
            _buildEvents.OnBuildBegin           += BuildEventsOnOnBuildBegin;
            _buildEvents.OnBuildDone            += BuildEventsOnOnBuildDone;
        }
Example #6
0
        protected override void Initialize()
        {
            base.Initialize();

            // Initialize common functionality
            Common.Initialize(this);
            taskListMenu = new RootMenu();

            // Initialize fields
            tools = new Tools();
            sharedTaskManagers = new List <TaskManager>();

            // Attach to solution events
            solution = GetService(typeof(SVsSolution)) as IVsSolution;
            // if (solution == null) throw new NullReferenceException();
            solution.AdviseSolutionEvents(this as IVsSolutionEvents, out solutionEventsCookie);

            // Attach to build events
            buildManager = GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager;
            // if (buildManager == null) throw new NullReferenceException();
            buildManager.AdviseUpdateSolutionEvents(this, out buildManagerCookie);

            // Add a TaskManagerFactory service
            (this as System.ComponentModel.Design.IServiceContainer).AddService(typeof(ITaskManagerFactory), this, true);
        }
Example #7
0
        internal SolutionEvents()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            IVsSolution svc = VS.GetRequiredService <SVsSolution, IVsSolution>();

            svc.AdviseSolutionEvents(this, out _);
        }
Example #8
0
        protected override void Initialize()
        {
            _solution = GetService(typeof(SVsSolution)) as IVsSolution;
            _solution.AdviseSolutionEvents(this, out _hSolutionEvents);

            base.Initialize();
        }
        internal void Register()
        {
            // Register this object to listen for IVsUpdateSolutionEvents
            IVsSolutionBuildManager2 buildManager = Package.GetService <SVsSolutionBuildManager, IVsSolutionBuildManager2>();

            if (buildManager == null)
            {
                throw Marshal.GetExceptionForHR(E_FAIL);
            }
            buildManager.AdviseUpdateSolutionEvents(this, out m_updateSolutionEventsCookie);

            // Register this object to listen for IVsSolutionEvents
            IVsSolution solution = Package.GetService <SVsSolution, IVsSolution>();

            if (solution == null)
            {
                throw Marshal.GetExceptionForHR(E_FAIL);
            }
            solution.AdviseSolutionEvents(this, out m_solutionEventsCookie);

            // Register this object to listen for IVsRunningDocTableEvents
            _runningDocTable = Package.GetService <SVsRunningDocumentTable, IVsRunningDocumentTable>();
            if (_runningDocTable == null)
            {
                throw Marshal.GetExceptionForHR(E_FAIL);
            }
            _runningDocTable.AdviseRunningDocTableEvents(this, out m_runningDocTableEventsCookie);
        }
Example #10
0
        public async Task InitializeAsync()
        {
            await _threadHandling.Value.SwitchToUIThread();

            // Initialize our cache file
            string appDataFolder = await _shellUtilitiesHelper.Value.GetLocalAppDataFolderAsync(_serviceProvider).ConfigureAwait(true);

            if (appDataFolder != null)
            {
                _versionDataCacheFile = new RemoteCacheFile(Path.Combine(appDataFolder, VersionDataFilename), VersionCompatibilityDownloadFwlink,
                                                            TimeSpan.FromHours(CacheFileValidHours), _fileSystem.Value, _httpClient);
            }

            _ourVSVersion = await _shellUtilitiesHelper.Value.GetVSVersionAsync(_serviceProvider).ConfigureAwait(true);

            IVsSolution solution = _serviceProvider.GetService <IVsSolution, SVsSolution>();

            Verify.HResult(solution.AdviseSolutionEvents(this, out _solutionCookie));

            // Check to see if a solution is already open. If so we set _solutionOpened to true so that subsequent projects added to
            // this solution are processed.
            if (ErrorHandler.Succeeded(solution.GetProperty((int)__VSPROPID4.VSPROPID_IsSolutionFullyLoaded, out object isFullyLoaded)) && isFullyLoaded is bool && (bool)isFullyLoaded)
            {
                _solutionOpened = true;
            }
        }
Example #11
0
        public TeamPilgrimVsService(TeamPilgrimPackage packageInstance, IVsUIShell vsUiShell, DTE2 dte2, IVsSolution vsSolution)
        {
            _teamFoundationBuild                     = new Lazy <VsTeamFoundationBuildWrapper>(() => new VsTeamFoundationBuildWrapper(_packageInstance.GetPackageService <IVsTeamFoundationBuild>()));
            _portalSettingsLauncher                  = new Lazy <IPortalSettingsLauncher>(() => _packageInstance.GetPackageService <IPortalSettingsLauncher>());
            _sourceControlSettingsLauncher           = new Lazy <ISourceControlSettingsLauncher>(() => _packageInstance.GetPackageService <ISourceControlSettingsLauncher>());
            _processTemplateManagerLauncher          = new Lazy <IProcessTemplateManagerLauncher>(() => _packageInstance.GetPackageService <IProcessTemplateManagerLauncher>());
            _workItemTrackingPackage                 = new Lazy <WorkItemTrackingPackageWrapper>();
            _versionControlPackage                   = new Lazy <VersionControlPackageWrapper>();
            _querySecurityCommandHelpers             = new Lazy <QuerySecurityCommandHelpersWrapper>();
            _pendingChangesPageViewModelUtilsWrapper = new Lazy <PendingChangesPageViewModelUtilsWrapper>();

            VsUiShell                       = vsUiShell;
            _packageInstance                = packageInstance;
            Dte2                            = dte2;
            VsSolution                      = vsSolution;
            VersionControlExt               = dte2.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;
            TeamFoundationServerExt         = dte2.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt") as TeamFoundationServerExt;
            WorkItemTrackingDocumentService = new DocumentServiceWrapper(dte2.GetObject("Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.DocumentService") as DocumentService);

            var teamFoundationHostObject = (ITeamFoundationContextManager)TeamFoundationServerExt_TeamFoundationHostField.Value.GetValue(TeamFoundationServerExt);

            TeamFoundationHost = new TeamFoundationHostWrapper(teamFoundationHostObject);

            vsSolution.AdviseSolutionEvents(this, out _adviseSolutionEventsCookie);
        }
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        /// <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()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString()));
            base.Initialize();

#if MEMPROFILER
            RedGate.MemoryProfiler.Snapshot.TakeSnapshot("Initialize");
#endif

            // listen for solution events
            _solution = (IVsSolution)GetService(typeof(SVsSolution));
            ErrorHandler.ThrowOnFailure(_solution.AdviseSolutionEvents(this, out _solutionCookie));

            if (_errorListProvider == null)
            {
                _errorListProvider = new TaskProvider(this);
            }

            // Commands
            IncludeFileCommand.Initialize(this, _errorListProvider);
            DeleteFileCommand.Initialize(this, _errorListProvider);
            ExcludeFileCommand.Initialize(this, _errorListProvider);

            _dte = (DTE)GetService(typeof(SDTE));
            var events = _dte.Events;
            _buildEvents = events.BuildEvents;

            Options = (OptionsDialogPage)GetDialogPage(typeof(OptionsDialogPage));

            _buildEvents.OnBuildProjConfigBegin += BuildEventsOnOnBuildProjConfigBegin;
            _buildEvents.OnBuildProjConfigDone  += BuildEventsOnBuildProjConfigDone;
            _buildEvents.OnBuildBegin           += BuildEventsOnOnBuildBegin;
            _buildEvents.OnBuildDone            += BuildEventsOnOnBuildDone;
        }
        public VisualStudioProjectTracker(IServiceProvider serviceProvider)
        {
            _projectMap = new Dictionary<ProjectId, AbstractProject>();
            _projectPathToIdMap = new Dictionary<string, ProjectId>(StringComparer.OrdinalIgnoreCase);

            _serviceProvider = serviceProvider;
            _workspaceHosts = new List<WorkspaceHostState>(capacity: 1);

            _vsSolution = (IVsSolution)serviceProvider.GetService(typeof(SVsSolution));
            _runningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable));

            uint solutionEventsCookie;
            _vsSolution.AdviseSolutionEvents(this, out solutionEventsCookie);
            _solutionEventsCookie = solutionEventsCookie;

            // It's possible that we're loading after the solution has already fully loaded, so see if we missed the event
            var shellMonitorSelection = (IVsMonitorSelection)serviceProvider.GetService(typeof(SVsShellMonitorSelection));

            uint fullyLoadedContextCookie;
            if (ErrorHandler.Succeeded(shellMonitorSelection.GetCmdUIContextCookie(VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_guid, out fullyLoadedContextCookie)))
            {
                int fActive;
                if (ErrorHandler.Succeeded(shellMonitorSelection.IsCmdUIContextActive(fullyLoadedContextCookie, out fActive)) && fActive != 0)
                {
                    _solutionLoadComplete = true;
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LocatorWindowCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private LocatorWindowCommand(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;

            OleMenuCommandService commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem = new MenuCommand(this.ShowToolWindow, menuCommandID);
                commandService.AddCommand(menuItem);
            }

            // Get the instance number 0 of this tool window. This window is single instance so this instance
            // is actually the only one.
            // The last flag is set to true so that if the tool window does not exists it will be created.
            _locatorWindow = package.FindToolWindow(typeof(LocatorWindow), 0, true) as LocatorWindow;
            if ((null == _locatorWindow) || (null == _locatorWindow.Frame))
            {
                throw new NotSupportedException("Cannot create tool window");
            }

            _locator = new Locator();
            _solution = ServiceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
            _solution.AdviseSolutionEvents(_locator, out _cookie);
            _locatorWindow.SetLocator(_locator);
            _locator.StartWorkerThread();
        }
Example #15
0
        protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await base.InitializeAsync(cancellationToken, progress);

            // NOTE: this switch is already performed within the base.InitializeAsync() method.
            await Microsoft.VisualStudio.Shell.ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

            _CurrentSolutionRcsType = RcsType.Unknown;

            //EnvDTE.IVsExtensibility extensibility = await GetServiceAsync(typeof(EnvDTE.IVsExtensibility)) as EnvDTE.IVsExtensibility;
            //_DTE2 = (DTE2)extensibility.GetGlobalsObject(null).DTE as EnvDTE80.DTE2;
            _DTE2 = Package.GetGlobalService(typeof(DTE)) as DTE2;

            IVsSolution solution = await GetServiceAsync(typeof(SVsSolution)) as IVsSolution;

            Assumes.Present(solution);
            int  hr;
            uint pdwCookie;

            hr = solution.AdviseSolutionEvents(this, out pdwCookie);
            Marshal.ThrowExceptionForHR(hr);

            _VsShell = await GetServiceAsync(typeof(SVsShell)) as IVsShell;

            _VsRegisterScciProvider = await GetServiceAsync(typeof(IVsRegisterScciProvider)) as IVsRegisterScciProvider;

            _VsGetScciProviderInterface = await GetServiceAsync(typeof(IVsRegisterScciProvider)) as IVsGetScciProviderInterface;

            _SettingsStore = GetWritableSettingsStore();

            TaskManager.Initialize(this);
            solutionEvents         = ((Events2)_DTE2.Events).SolutionEvents;
            solutionEvents.Opened += new _dispSolutionEvents_OpenedEventHandler(this.SolutionEvents_Opened);
            SolutionEvents_Opened();
        }
        protected override void Initialize()
        {
            base.Initialize();
            _updateLock = new object();
            IVsExtensibility extensibility = GetService <IVsExtensibility>();

            _DTE2    = (DTE2)extensibility.GetGlobalsObject(null).DTE;
            _Version = GetVersion(_DTE2.Version);

            _Solution = GetService <SVsSolution>() as IVsSolution;
            IVsCfgProvider2 test = _Solution as IVsCfgProvider2;

            _SolutionEvents = new SolutionEvents();
            int  hr;
            uint pdwCookie;

            hr = _Solution.AdviseSolutionEvents(_SolutionEvents, out pdwCookie);
            Marshal.ThrowExceptionForHR(hr);

            _UpdateSolutionEvents = new UpdateSolutionEvents();
            var vsSolutionBuildManager = GetService <SVsSolutionBuildManager>();

            hr = (vsSolutionBuildManager as IVsSolutionBuildManager3).AdviseUpdateSolutionEvents3(_UpdateSolutionEvents, out pdwCookie);
            Marshal.ThrowExceptionForHR(hr);
            hr = (vsSolutionBuildManager as IVsSolutionBuildManager2).AdviseUpdateSolutionEvents(_UpdateSolutionEvents, out pdwCookie);
            Marshal.ThrowExceptionForHR(hr);

            if (VersionGreaterEqualTo(DTEVersion.VS15))
            {
                LoadMef();
            }
        }
Example #17
0
        internal void InitProjectInfos(SVsServiceProvider provider, ABnfFactory factory)
        {
            if (factory == null)
            {
                return;
            }

            if (m_server != null)
            {
                return;
            }
            m_server = new ALanguageServer();
            m_server.Start(factory);

            if (m_cookie != 0)
            {
                return;
            }
            if (m_solution != null)
            {
                return;
            }
            m_solution = provider.GetService(typeof(SVsSolution)) as IVsSolution;
            if (m_solution == null)
            {
                return;
            }

            m_dot_ext   = factory.GetDotExt();
            m_file_icon = factory.GetFileIcon();

            // 读取所有工程
            m_projects.Clear();
            Guid             rguidEnumOnlyThisType = new Guid();
            IEnumHierarchies ppenum = null;

            m_solution.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref rguidEnumOnlyThisType, out ppenum);
            IVsHierarchy[] rgelt        = new IVsHierarchy[1];
            uint           pceltFetched = 0;

            while (ppenum.Next(1, rgelt, out pceltFetched) == VSConstants.S_OK && pceltFetched == 1)
            {
                IVsSccProject2 sccProject2 = rgelt[0] as IVsSccProject2;
                if (sccProject2 != null)
                {
                    string project_path = GetProjectPath(rgelt[0]);
                    if (project_path != null)
                    {
                        if (m_server != null)
                        {
                            m_server.AddTask(() => m_server.AddProjectInfo(project_path));
                        }
                        m_projects[rgelt[0]] = new UIProjectInfo(this, rgelt[0], project_path, m_dot_ext, m_file_icon);
                    }
                }
            }

            // 监听工程变化
            m_solution.AdviseSolutionEvents(this, out m_cookie);
        }
Example #18
0
        private void AdviseSolutionEvents()
        {
            UnadviseSolutionEvents();

            solution = GetService(typeof(SVsSolution)) as IVsSolution;
            solution?.AdviseSolutionEvents(this, out _handleCookie);
        }
        public async Task InitializeAsync()
        {
            await _threadHandling.Value.SwitchToUIThread();

            // Initialize our cache file
            string appDataFolder = await _shellUtilitiesHelper.Value.GetLocalAppDataFolderAsync(_vsShellService);

            if (appDataFolder != null)
            {
                _versionDataCacheFile = new RemoteCacheFile(Path.Combine(appDataFolder, VersionDataFilename), VersionCompatibilityDownloadFwlink,
                                                            TimeSpan.FromHours(CacheFileValidHours), _fileSystem.Value, _httpClient);
            }

            _ourVSVersion = await _shellUtilitiesHelper.Value.GetVSVersionAsync(_vsAppIdService);

            _vsSolution = await _vsSolutionService.GetValueAsync();

            Verify.HResult(_vsSolution.AdviseSolutionEvents(this, out _solutionCookie));

            // Check to see if a solution is already open. If so we set _solutionOpened to true so that subsequent projects added to
            // this solution are processed.
            if (ErrorHandler.Succeeded(_vsSolution.GetProperty((int)__VSPROPID4.VSPROPID_IsSolutionFullyLoaded, out object isFullyLoaded)) &&
                isFullyLoaded is bool isFullyLoadedBool &&
                isFullyLoadedBool)
            {
                _solutionOpened = true;
                // do not block package initialization on this
                _threadHandling.Value.RunAndForget(() => CheckCompatibilityAsync(), unconfiguredProject: null);
            }
        }
Example #20
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 initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await InitComponentsAsync();

            OleMenuCommandService commandService = await base.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

            MainPanelCommand.Initialize(this, commandService);
            await base.InitializeAsync(cancellationToken, progress);

            // Switch to main thread for dealing with type IVsSolution.
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            _solution = base.GetService(typeof(SVsSolution)) as IVsSolution;
            if (_solution != null)
            {
                _solutionEventsHandler = new SolutionEventsHandler();
                _solution.AdviseSolutionEvents(_solutionEventsHandler, out _solutionEventsCookie);
            }
            // To trigger upon loading a solution
            object      objLoadMgr = this; //the class that implements IVsSolutionManager
            IVsSolution pSolution  = GetService(typeof(SVsSolution)) as IVsSolution;

            object existingLoadManager = null;

            pSolution.GetProperty((int)__VSPROPID4.VSPROPID_ActiveSolutionLoadManager, out existingLoadManager);
            pSolution.SetProperty((int)__VSPROPID4.VSPROPID_ActiveSolutionLoadManager, objLoadMgr);
        }
        public VisualStudioProjectTracker(IServiceProvider serviceProvider, HostWorkspaceServices workspaceServices)
            : base(assertIsForeground: true)
        {
            _projectMap         = new Dictionary <ProjectId, AbstractProject>();
            _projectPathToIdMap = new Dictionary <string, ProjectId>(StringComparer.OrdinalIgnoreCase);

            _serviceProvider   = serviceProvider;
            _workspaceHosts    = new List <WorkspaceHostState>(capacity: 1);
            _workspaceServices = workspaceServices;

            _vsSolution           = (IVsSolution)serviceProvider.GetService(typeof(SVsSolution));
            _runningDocumentTable = (IVsRunningDocumentTable4)serviceProvider.GetService(typeof(SVsRunningDocumentTable));
            _vsSolution.AdviseSolutionEvents(this, out var solutionEventsCookie);
            _solutionEventsCookie = solutionEventsCookie;

            // It's possible that we're loading after the solution has already fully loaded, so see if we missed the event
            var shellMonitorSelection = (IVsMonitorSelection)serviceProvider.GetService(typeof(SVsShellMonitorSelection));

            if (ErrorHandler.Succeeded(shellMonitorSelection.GetCmdUIContextCookie(VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_guid, out var fullyLoadedContextCookie)))
            {
                if (ErrorHandler.Succeeded(shellMonitorSelection.IsCmdUIContextActive(fullyLoadedContextCookie, out var fActive)) && fActive != 0)
                {
                    _solutionLoadComplete = true;
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="FuzzyOpenCommand"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        private FuzzyOpenCommand(Package package)
        {
            if (package == null)
            {
                throw new ArgumentNullException("package");
            }

            this.package = package;
            mDTE         = FuzzyOpenPackage.GetGlobalService(typeof(DTE)) as DTE;
            mAllItems    = mLoadAllFiles();
            mSvs         = FuzzyOpenPackage.GetGlobalService(typeof(SVsSolution)) as IVsSolution;
            if (mSvs != null)
            {
                mSvs.AdviseSolutionEvents(this, out mAdviseId);
            }

            ((EnvDTE80.Events2)mDTE.Events).ProjectItemsEvents.ItemAdded   += ProjectItemsEvents_ItemAdded;
            ((EnvDTE80.Events2)mDTE.Events).ProjectItemsEvents.ItemRemoved += ProjectItemsEvents_ItemRemoved;
            ((EnvDTE80.Events2)mDTE.Events).ProjectItemsEvents.ItemRenamed += ProjectItemsEvents_ItemRenamed;
            //((EnvDTE80.Events2)mDTE.Events).ProjectsEvents.ItemAdded TODO
            //((EnvDTE80.Events2)mDTE.Events).ProjectsEvents.ItemRemoved
            //((EnvDTE80.Events2)mDTE.Events).ProjectsEvents.ItemRenamed

            OleMenuCommandService commandService = this.ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (commandService != null)
            {
                var menuCommandID = new CommandID(CommandSet, CommandId);
                var menuItem      = new MenuCommand(this.MenuItemCallback, menuCommandID);
                commandService.AddCommand(menuItem);
            }
        }
        /// <include file='doc\ShellLicenseManagerService.uex' path='docs/doc[@for="ShellLicenseManagerService.ShellLicenseManagerService"]/*' />
        /// <devdoc>
        ///      Creates a new type loader service.
        /// </devdoc>
        public ShellLicenseManagerService(IServiceProvider provider)
        {
            this.provider = provider;

            // We need to track solution events.
            //
            IVsSolution sol = (IVsSolution)GetService(typeof(IVsSolution));

            #if DEBUG
            if (Switches.LICMANAGER.TraceVerbose)
            {
                if (sol == null)
                {
                    Debug.WriteLine("ShellLicenseManager : No solution found");
                }
                else
                {
                    Debug.WriteLine("ShellLicenseManager : Attaching solution events");
                }
            }
            #endif

            if (sol != null)
            {
                solutionEventsCookie = sol.AdviseSolutionEvents(this);
            }
        }
        /// <include file='doc\ShellTypeLoaderService.uex' path='docs/doc[@for="ShellTypeLoaderService.ShellTypeLoaderService"]/*' />
        /// <devdoc>
        ///      Creates a new type loader service.
        /// </devdoc>
        public ShellTypeLoaderService(IServiceProvider provider)
        {
            this.provider = provider;

            // We need to track solution events.
            //
            IVsSolution sol = (IVsSolution)GetService(typeof(IVsSolution));

            #if DEBUG
            if (Switches.TYPELOADER.TraceVerbose)
            {
                if (sol == null)
                {
                    Debug.WriteLine("TypeLoader : No solution found");
                }
                else
                {
                    Debug.WriteLine("TypeLoader : Attaching solution events");
                }
            }
            #endif

            if (sol != null)
            {
                solutionEventsCookie = sol.AdviseSolutionEvents(this);
            }

            ShellTypeLoader.ClearProjectAssemblyCache();
        }
        /// <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 async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress)
        {
            await base.InitializeAsync(cancellationToken, progress);

            _dte = await GetServiceAsync <DTE>();

            var serviceProvider = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)_dte);
            var dialogService   = new VisualStudioDialogService(serviceProvider);
            var commandService  = await GetServiceAsync <IMenuCommandService>();

            var projectService  = new VcProjectService();
            var settingsService = new VisualStudioSettingsService(this);

            _solution = await GetServiceAsync <SVsSolution>() as IVsSolution;

            _solutionEventsHandler = new SolutionEventsHandler(this);
            _solution.AdviseSolutionEvents(_solutionEventsHandler, out var _solutionEventsCookie);

            _addConanDepends             = new AddConanDepends(commandService, dialogService, projectService, settingsService);
            _showPackageListCommand      = new ShowPackageListCommand(this, commandService, dialogService);
            _integrateIntoProjectCommand = new IntegrateIntoProjectCommand(commandService, dialogService, projectService);

            Logger.Initialize(serviceProvider, "Conan");

            SubscribeToEvents();
        }
 public SolutionsEventListener(GaugeDaemonOptions gaugeDaemonOptions, IServiceProvider serviceProvider)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     _gaugeDaemonOptions = gaugeDaemonOptions;
     _solution           = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
     ErrorHandler.ThrowOnFailure(_solution.AdviseSolutionEvents(this, out _solutionCookie));
 }
Example #27
0
        public SolutionEventsListener(IServiceProvider serviceProvider)
        {
            _solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread
            _solution?.AdviseSolutionEvents(this, out _solutionEventsCookie);
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
        }
Example #28
0
        public SolutionEvent(IVsSolution Solution, EnvDTE.DTE ctxDte)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            dte = ctxDte;
            Solution.AdviseSolutionEvents(this, out cookie);
        }
Example #29
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()
        {
            ToolStripManager.Renderer = new VisualStudioLikeToolStripRenderer();

            // Add the Text Marker Service to the service container. The container will care
            // about all the rest (proffer the service, revoke it, and so on).
            CloneMarkerTypeProvider markerTypeProvider = new CloneMarkerTypeProvider();

            ((IServiceContainer)this).AddService(markerTypeProvider.GetType(), markerTypeProvider, true);

            base.Initialize();

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

            if (null != mcs)
            {
                // Create the commands for the tool windows.
                CommandID   cloneExplorerCommandID = new CommandID(Guids.GuidCommandSet, (int)PkgCmdid.CmdidCloneExplorer);
                MenuCommand cloneExplorerMenuItem  = new MenuCommand(ShowCloneExplorer, cloneExplorerCommandID);
                mcs.AddCommand(cloneExplorerMenuItem);

                CommandID   cloneIntersectionsCommandID = new CommandID(Guids.GuidCommandSet, (int)PkgCmdid.CmdidCloneIntersections);
                MenuCommand cloneIntersectionsMenuItem  = new MenuCommand(ShowCloneIntersections, cloneIntersectionsCommandID);
                mcs.AddCommand(cloneIntersectionsMenuItem);

                CommandID   cloneResultsCommandID = new CommandID(Guids.GuidCommandSet, (int)PkgCmdid.CmdidCloneResults);
                MenuCommand cloneResultsMenuItem  = new MenuCommand(ShowCloneResults, cloneResultsCommandID);
                mcs.AddCommand(cloneResultsMenuItem);
            }

            // Advise event sinks. We need to know when a solution is opened and closed
            // (SolutionEventSink), when a document is opened and closed (TextManagerEventSink),
            // and when a document is saved (RunningDocTableEventSink).
            //
            // However unfortunately we can't advise the text manager event sink here due to a very
            // strange constellation: On Windows XP running "devenv /setup" usually works fine but
            // sometimes destruction of the text manager service crashes VS. The solution is to defer
            // event sink registration to the point in time when the first solution is loaded. This works
            // as solutions are only loaded in interactive mode and we don't have any work to do as long
            // as there is no active solution.
            SolutionEventSink        solutionEventSink        = new SolutionEventSink();
            RunningDocTableEventSink runningDocTableEventSink = new RunningDocTableEventSink();

            IVsSolution solution = (IVsSolution)GetService(typeof(SVsSolution));

            ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(solutionEventSink, out _solutionEventCookie));

            IVsRunningDocumentTable rdt = (IVsRunningDocumentTable)GetService(typeof(SVsRunningDocumentTable));

            ErrorHandler.ThrowOnFailure(rdt.AdviseRunningDocTableEvents(runningDocTableEventSink, out _rdtEventCookie));

            // Since we register custom text markers we have to ensure the font and color
            // cache is up-to-date.
            ValidateFontAndColorCacheManagerIsUpToDate();

            // Ensure settings are initialized correctly.
            InitializeUserSettings();
        }
Example #30
0
        protected override void Initialize()
        {
            Trace.WriteLine(String.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            try
            {
                errorList       = new VSTools.ErrorList.Pane(this);
                Log._.Received -= onLogReceived;
                Log._.Received += onLogReceived;

                initAppEvents();

                OleMenuCommandService mcs = (OleMenuCommandService)GetService(typeof(IMenuCommandService));

                // Build / <Main App>
                _menuItemMain         = new MenuCommand(_menuMainCallback, new CommandID(GuidList.MAIN_CMD_SET, (int)PkgCmdIDList.CMD_MAIN));
                _menuItemMain.Visible = false;
                mcs.AddCommand(_menuItemMain);

                // View / Other Windows / <Status Panel>
                mcs.AddCommand(new MenuCommand(_menuPanelCallback, new CommandID(GuidList.PANEL_CMD_SET, (int)PkgCmdIDList.CMD_PANEL)));

                // To listen events that fired as a IVsSolutionEvents
                spSolution = (IVsSolution)ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution));
                spSolution.AdviseSolutionEvents(this, out _pdwCookieSolution);

                // To listen events that fired as a IVsUpdateSolutionEvents2
                spSolutionBM = (IVsSolutionBuildManager2)ServiceProvider.GlobalProvider.GetService(typeof(SVsSolutionBuildManager));
                spSolutionBM.AdviseUpdateSolutionEvents(this, out _pdwCookieSolutionBM);
            }
            catch (Exception ex)
            {
                string msg = string.Format("{0}\n{1}\n\n-----\n{2}",
                                           "Something went wrong -_-",
                                           "Try to restart IDE or reinstall current plugin in Extension Manager.",
                                           ex.ToString());

                Debug.WriteLine(msg);

                int        res;
                Guid       id      = Guid.Empty;
                IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));

                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                    uiShell.ShowMessageBox(
                        0,
                        ref id,
                        "Initialize vsSolutionBuildEvent",
                        msg,
                        string.Empty,
                        0,
                        OLEMSGBUTTON.OLEMSGBUTTON_OK,
                        OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                        OLEMSGICON.OLEMSGICON_WARNING,
                        0,
                        out res));
            }
        }
        /// <summary>
        /// Constructor.
        /// Register Solution events.
        /// </summary>
        public SolutionChangeEventListener() {
            InitNullEvents();

            solution = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;
            if(solution != null) {
                solution.AdviseSolutionEvents(this, out solutionEventsCookie);
            }
        }
Example #32
0
 private void AdviceSolutionEvents()
 {
     solution = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;
     if (solution != null)
     {
         ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(this, out solutionCookie));
     }
 }
 public SolutionEventsListener(IServiceProvider serviceProvider)
 {
     solution = serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
     if (solution != null)
     {
         solution.AdviseSolutionEvents(this, out solutionEventsCookie);
     }
 }
Example #34
0
 private void AdviceSolutionEvents()
 {
     solution = Package.GetGlobalService(typeof(SVsSolution)) as IVsSolution;
     if (solution != null)
     {
         ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(this, out solutionCookie));
     }
 }
            public SolutionEvents(TestServices testServices, IVsSolution solution)
            {
                testServices.ThrowIfNotOnMainThread();

                _joinableTaskFactory = testServices.JoinableTaskFactory;
                _solution            = solution;
                ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(this, out _cookie));
            }
 public SolutionEventSinks()
 {
     solution = (IVsSolution)Package.GetGlobalService(typeof(SVsSolution));
     if (null == solution)
         Trace.WriteLine("Can't access solution service");
     else
         solution.AdviseSolutionEvents((IVsSolutionEvents)this, out solutionEventsCookie);
 }
        public SolutionEventListener([Import(typeof (SVsServiceProvider))] IServiceProvider serviceProvider)
        {
            ValidateArg.NotNull(serviceProvider, "serviceProvider");
            _solution = (IVsSolution) serviceProvider.GetService(typeof (IVsSolution));

            if (_solution != null)
            {
                _solution.AdviseSolutionEvents(this, out _solutionEventsCookie);
            }
        }
 public SolutionEvent(ServiceProvider sp)
 {
     serviceProvider = sp;
     solution = (IVsSolution)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(IVsSolution));
     dte = (EnvDTE.DTE)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(EnvDTE.DTE));
     //serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
     if (solution != null)
     {
         solution.AdviseSolutionEvents(this, out solutionEventsCookie);
     }
 }
        public XamlTextViewCreationListener(
            [Import(typeof(SVsServiceProvider))] System.IServiceProvider services,
            ICommandHandlerServiceFactory commandHandlerServiceFactory,
            IVsEditorAdaptersFactoryService editorAdaptersFactoryService,
            IXamlDocumentAnalyzerService analyzerService,
            VisualStudioWorkspaceImpl vsWorkspace)
        {
            _serviceProvider = services;
            _commandHandlerService = commandHandlerServiceFactory;
            _editorAdaptersFactory = editorAdaptersFactoryService;
            _vsWorkspace = vsWorkspace;
            _rdt = new Lazy<RunningDocumentTable>(() => new RunningDocumentTable(_serviceProvider));
            _vsSolution = (IVsSolution)_serviceProvider.GetService(typeof(SVsSolution));

            AnalyzerService = analyzerService;

            uint solutionEventsCookie;
            if (ErrorHandler.Succeeded(_vsSolution.AdviseSolutionEvents(this, out solutionEventsCookie)))
            {
                _solutionEventsCookie = solutionEventsCookie;
            }
        }
Example #40
0
        public SolutionService(IServiceProvider serviceProvider, SourceControlProvider sourceControlProvider)
        {
            _serviceProvider = serviceProvider;
            _vsSolution = serviceProvider.GetService<SVsSolution, IVsSolution>();
            _isRefreshEnabled = true;

            sourceControlProvider.Activated += (sender, e) =>
            {
                string directory, fileName, userFile;
                _vsSolution.GetSolutionInfo(out directory, out fileName, out userFile);

                _vsSolution.AdviseSolutionEvents(this, out _cookieSolutionEvents);
                if (string.IsNullOrEmpty(directory))
                    _repositoryService.CloseRepository();
                else
                    _repositoryService.OpenRepositoryAt(directory);
            };

            sourceControlProvider.Deactivated += (sender, e) =>
            {
                StopListeningToSolutionEvents();
                _repositoryService.CloseRepository();
            };
        }
        /// <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()
        {
            UnityRefactorHelperSettingsCommand.Initialize(this);
            base.Initialize();

            Cache.Instance.OleMenuCommandService = GetService(typeof (IMenuCommandService)) as OleMenuCommandService;
            Cache.Instance.Dte = (DTE) GetService(typeof (SDTE));

            var events = Cache.Instance.Dte.Events;
            _documentEvents = events.DocumentEvents;
            _buildEvents = events.BuildEvents;

            Cache.Instance.SolutionService = GetService(typeof (IVsSolution)) as IVsSolution;

            _solutionEvents = new SolutionEvents();
            _solution = GetService(typeof (SVsSolution)) as IVsSolution;
            _solution.AdviseSolutionEvents(_solutionEvents, out _solutionEventsCookie);

            _documentEvents.DocumentSaved += DocumentEventsOnDocumentSaved;
            _buildEvents.OnBuildProjConfigDone += BuildEventsOnOnBuildProjConfigDone;
        }
Example #42
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 initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Debug.WriteLine("Entering Initialize() of: {0}", ToString());
            base.Initialize();

            _vsSolution = (IVsSolution) GetService(typeof (SVsSolution));
            _vsSolution.AdviseSolutionEvents(this, out _cookie);
        }
        protected override void Initialize()
        {
            Trace.WriteLine(String.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", ToString()));
            base.Initialize();

            try
            {
                errorList       = new VSTools.ErrorList.Pane(this);
                Log._.Received  -= onLogReceived;
                Log._.Received  += onLogReceived;

                OleMenuCommandService mcs = (OleMenuCommandService)GetService(typeof(IMenuCommandService));

                // Top Menu
                _menuItemMain = new MenuCommand(_menuMainCallback, new CommandID(GuidList.CMD_MAIN, PkgCmdIDList.CMD_MAIN));
                _menuItemMain.Visible = false;
                mcs.AddCommand(_menuItemMain);

                mcs.AddCommand(
                    new MenuCommand(
                        _menuCfgUnwarnCallback,
                        new CommandID(GuidList.CMD_MAIN, PkgCmdIDList.CMD_UNWARN)
                    )
                );

                // To listen events that fired as a IVsSolutionEvents
                spSolution = (IVsSolution)ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution));
                spSolution.AdviseSolutionEvents(this, out _pdwCookieSolution);

                initAppEvents();
            }
            catch(Exception ex)
            {
                string msg = string.Format("{0}\n{1}\n\n-----\n{2}",
                                "Something went wrong -_-",
                                "Try to restart IDE or reinstall current plugin in Extension Manager.",
                                ex.ToString());

                Debug.WriteLine(msg);

                int res;
                Guid id = Guid.Empty;
                IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));

                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                    uiShell.ShowMessageBox(
                           0,
                           ref id,
                           "Initialize vsCommandEvent",
                           msg,
                           string.Empty,
                           0,
                           OLEMSGBUTTON.OLEMSGBUTTON_OK,
                           OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                           OLEMSGICON.OLEMSGICON_WARNING,
                           0,
                           out res));
            }
        }
Example #44
0
    protected override void Initialize()
    {
      Common.Trace("Package intialize");
      base.Initialize();
      Common.Trace("Task manager.Initialize()");

      // Initialize common functionality
      Common.Initialize(this);
      taskListMenu = new RootMenu();
      
      // Initialize fields
      tools = new Tools();
      sharedTaskManagers = new List<TaskManager>();

      // Attach to solution events
      solution = GetService(typeof(SVsSolution)) as IVsSolution;
      if (solution == null) Common.Log("Could not get solution");
      solution.AdviseSolutionEvents(this as IVsSolutionEvents, out solutionEventsCookie);

      // Attach to build events
      buildManager = GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager;
      if (buildManager == null) Common.Log("Could not get build manager");
      buildManager.AdviseUpdateSolutionEvents(this, out buildManagerCookie);

      // Add a TaskManagerFactory service
      ITaskManagerFactory factory = this as ITaskManagerFactory;
      (this as System.ComponentModel.Design.IServiceContainer).AddService(typeof(ITaskManagerFactory), factory, true);

      // Set PID for msbuild tasks
      Environment.SetEnvironmentVariable( "VSPID", System.Diagnostics.Process.GetCurrentProcess().Id.ToString() );
    }
Example #45
0
        /// <summary>
        /// Defines listeners for main events.
        /// </summary>
        private void adviseEvents()
        {
            // To listen events that fired as a IVsSolutionEvents
            spSolution = (IVsSolution)ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution));
            spSolution.AdviseSolutionEvents(this, out _pdwCookieSolution);

            // To listen events that fired as a IVsUpdateSolutionEvents2
            spSolutionBM = (IVsSolutionBuildManager2)ServiceProvider.GlobalProvider.GetService(typeof(SVsSolutionBuildManager));
            spSolutionBM.AdviseUpdateSolutionEvents(this, out _pdwCookieSolutionBM);
        }
 public SolutionEventsSink(IMessageBus messageBus, IVsSolution solution)
 {
     _messageBus = messageBus;
     _solution = solution;
     solution.AdviseSolutionEvents(this, out _cookie);
 }
Example #47
0
    protected override void Initialize()
    {
      base.Initialize();
      
      // Initialize common functionality
      Common.Initialize(this);
      taskListMenu = new RootMenu();
      
      // Initialize fields
      tools = new Tools();
      sharedTaskManagers = new List<TaskManager>();

      // Attach to solution events
      solution = GetService(typeof(SVsSolution)) as IVsSolution;
      // if (solution == null) throw new NullReferenceException();
      solution.AdviseSolutionEvents(this as IVsSolutionEvents, out solutionEventsCookie);

      // Attach to build events
      buildManager = GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager;
      // if (buildManager == null) throw new NullReferenceException();
      buildManager.AdviseUpdateSolutionEvents(this, out buildManagerCookie);

      // Add a TaskManagerFactory service
      (this as System.ComponentModel.Design.IServiceContainer).AddService(typeof(ITaskManagerFactory), this, true);
    }
partial         void AdviseSolutionEvents()
        {
            solution = (IVsSolution)GetService(typeof(SVsSolution));
            solution.AdviseSolutionEvents(this, out solutionEventsCookie);
        }
Example #49
0
 public SolutionAdvisor(IVsSolution solution)
 {
     ErrorHandler.ThrowOnFailure(solution.AdviseSolutionEvents(this, out _cookie));
 }
 public AzureSolutionListener(IServiceProvider serviceProvider) {
     _serviceProvider = serviceProvider;
     _solution = _serviceProvider.GetService(typeof(SVsSolution)) as IVsSolution;
     ErrorHandler.ThrowOnFailure(_solution.AdviseSolutionEvents(this, out _eventsCookie));
 }
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation
        /// <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()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            // listen for solution events
            _solution = (IVsSolution)GetService(typeof(SVsSolution));
            ErrorHandler.ThrowOnFailure(_solution.AdviseSolutionEvents(this, out _solutionCookie));

            _dte = (DTE)GetService(typeof(SDTE));
            var events = _dte.Events;
            _buildEvents = events.BuildEvents;

            if (_errorListProvider == null)
                _errorListProvider = new ErrorListProvider(this);

            Dispatcher.CurrentDispatcher.BeginInvoke(new Action(() =>
             {
                 Options = (ShowMissingOptions)GetDialogPage(typeof(ShowMissingOptions));
             }), DispatcherPriority.ApplicationIdle, null);

            _buildEvents.OnBuildProjConfigBegin += BuildEventsOnOnBuildProjConfigBegin;
            _buildEvents.OnBuildBegin += BuildEventsOnOnBuildBegin;
            _buildEvents.OnBuildDone += BuildEventsOnOnBuildDone;
        }
        protected override void Initialize()
        {
            Trace.WriteLine(String.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            try
            {
                initAppEvents();

                OleMenuCommandService mcs = (OleMenuCommandService)GetService(typeof(IMenuCommandService));

                // Build / <Main App>
                _menuItemMain = new MenuCommand(_menuMainCallback, new CommandID(GuidList.MAIN_CMD_SET, (int)PkgCmdIDList.CMD_MAIN));
                _menuItemMain.Visible = false;
                mcs.AddCommand(_menuItemMain);

                // View / Other Windows / <Status Panel>
                mcs.AddCommand(new MenuCommand(_menuPanelCallback, new CommandID(GuidList.PANEL_CMD_SET, (int)PkgCmdIDList.CMD_PANEL)));

                // To listen events that fired as a IVsSolutionEvents
                spSolution = (IVsSolution)ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution));
                spSolution.AdviseSolutionEvents(this, out _pdwCookieSolution);

                // To listen events that fired as a IVsUpdateSolutionEvents2
                spSolutionBM = (IVsSolutionBuildManager2)ServiceProvider.GlobalProvider.GetService(typeof(SVsSolutionBuildManager));
                spSolutionBM.AdviseUpdateSolutionEvents(this, out _pdwCookieSolutionBM);
            }
            catch(Exception ex)
            {
                string msg = string.Format("{0}\n{1}\n\n-----\n{2}",
                                "Something went wrong -_-",
                                "Try to restart IDE or reinstall current plugin in Extension Manager.",
                                ex.ToString());

                Log.Fatal(msg);

                int res;
                Guid id = Guid.Empty;
                IVsUIShell uiShell = (IVsUIShell)GetService(typeof(SVsUIShell));

                Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(
                    uiShell.ShowMessageBox(
                           0,
                           ref id,
                           "Initialize vsSolutionBuildEvent",
                           msg,
                           string.Empty,
                           0,
                           OLEMSGBUTTON.OLEMSGBUTTON_OK,
                           OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
                           OLEMSGICON.OLEMSGICON_WARNING,
                           0,
                           out res));
            }
        }
        protected override void Initialize()
        {
            base.Initialize();

            AddMenuCommands();

            _solution = GetService(typeof (SVsSolution)) as IVsSolution;
            if (_solution != null)
                _solution.AdviseSolutionEvents(this, out _dwCookie);

            var dte = (DTE)GetService(typeof(DTE));

            var itemOperations = new ItemOperationsWrapper(dte);
            var solutionFolderWrapper = new SolutionFolderWrapper(dte);
            var defaultDocumentPolicy = new DefaultDocumentPolicy();
            var server = new WebServer();
            _impl = new WelcomePageImpl(solutionFolderWrapper, defaultDocumentPolicy, itemOperations, server);
        }
        public TeamPilgrimVsService(TeamPilgrimPackage packageInstance, IVsUIShell vsUiShell, DTE2 dte2, IVsSolution vsSolution)
        {
            _teamFoundationBuild = new Lazy<VsTeamFoundationBuildWrapper>(() => new VsTeamFoundationBuildWrapper(_packageInstance.GetPackageService<IVsTeamFoundationBuild>()));
            _portalSettingsLauncher = new Lazy<IPortalSettingsLauncher>(() => _packageInstance.GetPackageService<IPortalSettingsLauncher>());
            _sourceControlSettingsLauncher = new Lazy<ISourceControlSettingsLauncher>(() => _packageInstance.GetPackageService<ISourceControlSettingsLauncher>());
            _processTemplateManagerLauncher = new Lazy<IProcessTemplateManagerLauncher>(() => _packageInstance.GetPackageService<IProcessTemplateManagerLauncher>());
            _workItemTrackingPackage = new Lazy<WorkItemTrackingPackageWrapper>();
            _versionControlPackage = new Lazy<VersionControlPackageWrapper>();
            _querySecurityCommandHelpers = new Lazy<QuerySecurityCommandHelpersWrapper>();
            _pendingChangesPageViewModelUtilsWrapper = new Lazy<PendingChangesPageViewModelUtilsWrapper>();

            VsUiShell = vsUiShell;
            _packageInstance = packageInstance;
            Dte2 = dte2;
            VsSolution = vsSolution;
            VersionControlExt = dte2.GetObject("Microsoft.VisualStudio.TeamFoundation.VersionControl.VersionControlExt") as VersionControlExt;
            TeamFoundationServerExt = dte2.GetObject("Microsoft.VisualStudio.TeamFoundation.TeamFoundationServerExt") as TeamFoundationServerExt;
            WorkItemTrackingDocumentService = new DocumentServiceWrapper(dte2.GetObject("Microsoft.VisualStudio.TeamFoundation.WorkItemTracking.DocumentService") as DocumentService);

            var teamFoundationHostObject = (ITeamFoundationContextManager)TeamFoundationServerExt_TeamFoundationHostField.Value.GetValue(TeamFoundationServerExt);
            TeamFoundationHost = new TeamFoundationHostWrapper(teamFoundationHostObject);

            vsSolution.AdviseSolutionEvents(this, out _adviseSolutionEventsCookie);
        }
Example #55
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 initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            //// Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
            if (null != mcs)
            {
                CommandID slncmd = new CommandID(GuidList.guidNuSightCmdSet, (int)PkgCmdIDList.cmdBindSymbol);
                MenuCommand mBind = new MenuCommand(BindSymbols, slncmd);
                mcs.AddCommand(mBind);

                CommandID vslcmd = new CommandID(GuidList.guidNuSightCmdSet, (int)PkgCmdIDList.cmdVisualize);
                MenuCommand mVisual = new MenuCommand(Visualize, vslcmd);
                mcs.AddCommand(mVisual);
            }

            _solution = ServiceProvider.GlobalProvider.GetService(typeof(SVsSolution)) as IVsSolution2;
            if (_solution != null)
            {
                // Register for solution events
                _solution.AdviseSolutionEvents(this, out _solutionEventsCookie);
            }
        }
Example #56
0
        protected override void Initialize()
        {
            RegisterProjectFactory(new MonoTouch26FlavorProjectFactory(this));
            RegisterProjectFactory(new MonoTouch28FlavorProjectFactory(this));

            _dte = GetService(typeof(SDTE)) as DTE;
            if (_dte == null) throw new Exception("DTE Reference Not Found");

            _buildEvents = _dte.Events.BuildEvents;
            _buildEvents.OnBuildBegin += MakeXibsNone;
            _buildEvents.OnBuildDone += MakeXibsPage;

            _solution = (IVsSolution)GetService(typeof(SVsSolution));
            if (_solution == null) throw new Exception("IVSSolution Reference Not Found.");
            _solution.AdviseSolutionEvents(_solutionEvents, out _solutionEventsCookie);

            base.Initialize();
        }