public SccProviderService(BasicSccProvider sccProvider, List<GitFileStatusTracker> trackers) { this._sccProvider = sccProvider; this.trackers = trackers; // Subscribe to solution events IVsSolution sol = (IVsSolution)sccProvider.GetService(typeof(SVsSolution)); sol.AdviseSolutionEvents(this, out _vsSolutionEventsCookie); var sbm = sccProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2; if (sbm != null) { sbm.AdviseUpdateSolutionEvents(this, out _vsIVsUpdateSolutionEventsCookie); } }
public SccProviderService(BasicSccProvider sccProvider, List <GitFileStatusTracker> trackers) { this._sccProvider = sccProvider; this.trackers = trackers; // Subscribe to solution events IVsSolution sol = (IVsSolution)sccProvider.GetService(typeof(SVsSolution)); sol.AdviseSolutionEvents(this, out _vsSolutionEventsCookie); var sbm = sccProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2; if (sbm != null) { sbm.AdviseUpdateSolutionEvents(this, out _vsIVsUpdateSolutionEventsCookie); } }
public static T GetServiceEx <T>() { if (_SccProvider == null) { return(default(T)); } return((T)_SccProvider.GetService(typeof(T))); }
public void Dispose() { // Unregister from receiving solution events if (VSConstants.VSCOOKIE_NIL != _vsSolutionEventsCookie) { IVsSolution sol = (IVsSolution)_sccProvider.GetService(typeof(SVsSolution)); sol.UnadviseSolutionEvents(_vsSolutionEventsCookie); _vsSolutionEventsCookie = VSConstants.VSCOOKIE_NIL; } if (VSConstants.VSCOOKIE_NIL != _vsIVsUpdateSolutionEventsCookie) { var sbm = _sccProvider.GetService(typeof(SVsSolutionBuildManager)) as IVsSolutionBuildManager2; sbm.UnadviseUpdateSolutionEvents(_vsIVsUpdateSolutionEventsCookie); } }
private async Task SetSolutionExplorerTitle(string message) { await ThreadHelper.JoinableTaskFactory.RunAsync( VsTaskRunContext.UIThreadBackgroundPriority, async delegate { // On caller's thread. Switch to main thread (if we're not already there). await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); // Now on UI thread via background priority. await Task.Yield(); // Resumed on UI thread, also via background priority. var dte = (DTE)_sccProvider.GetService(typeof(DTE)); dte.Windows.Item(EnvDTE.Constants.vsWindowKindSolutionExplorer).Caption = message; }); }
public void HookCommand(CommandID command, EventHandler handler) { if (command == null) { throw new ArgumentNullException("command"); } else if (handler == null) { throw new ArgumentNullException("handler"); } Dictionary <int, EventHandler> map; if (!_commandMap.TryGetValue(command.Guid, out map)) { map = new Dictionary <int, EventHandler>(); _commandMap[command.Guid] = map; } EventHandler handlers; if (!map.TryGetValue(command.ID, out handlers)) { handlers = null; } map[command.ID] = (handlers + handler); if (!_hooked) { ThreadHelper.ThrowIfNotOnUIThread(); IVsRegisterPriorityCommandTarget svc = (IVsRegisterPriorityCommandTarget)_provider.GetService(typeof(SVsRegisterPriorityCommandTarget)); if (svc != null && ErrorHandler.Succeeded(svc.RegisterPriorityCommandTarget(0, this, out _cookie))) { _hooked = true; } } }