private void Initialize() { var componentModel = ServiceLocator.GetGlobalService <SComponentModel, IComponentModel>(); // ensure we satisfy our imports componentModel?.DefaultCompositionService.SatisfyImportsOnce(this); }
public VSSolutionManager() { _dte = ServiceLocator.GetInstance <DTE>(); _vsSolution = ServiceLocator.GetGlobalService <SVsSolution, IVsSolution>(); _vsMonitorSelection = ServiceLocator.GetGlobalService <SVsShellMonitorSelection, IVsMonitorSelection>(); // Keep a reference to SolutionEvents so that it doesn't get GC'ed. Otherwise, we won't receive events. _solutionEvents = _dte.Events.SolutionEvents; // can be null in unit tests if (_vsMonitorSelection != null) { Guid solutionLoadedGuid = VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_guid; _vsMonitorSelection.GetCmdUIContextCookie(ref solutionLoadedGuid, out _solutionLoadedUICookie); uint cookie; int hr = _vsMonitorSelection.AdviseSelectionEvents(this, out cookie); ErrorHandler.ThrowOnFailure(hr); } _solutionEvents.BeforeClosing += OnBeforeClosing; _solutionEvents.AfterClosing += OnAfterClosing; _solutionEvents.ProjectAdded += OnEnvDTEProjectAdded; _solutionEvents.ProjectRemoved += OnEnvDTEProjectRemoved; _solutionEvents.ProjectRenamed += OnEnvDTEProjectRenamed; }
private void InitForBindingRedirects() { if (!BindingRedirectsRelatedInitialized) { var solutionManager = ServiceLocator.GetInstanceSafe <ISolutionManager>(); VSSolutionManager = (solutionManager != null) ? (solutionManager as VSSolutionManager) : null; VSFrameworkMultiTargeting = ServiceLocator.GetGlobalService <SVsFrameworkMultiTargeting, IVsFrameworkMultiTargeting>(); } }
private void Initialize() { var componentModel = ServiceLocator.GetGlobalService <SComponentModel, IComponentModel>(); // ensure we satisfy our imports and access DTE on the UI thread NuGetUIThreadHelper.JoinableTaskFactory.Run( async delegate { await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); componentModel?.DefaultCompositionService.SatisfyImportsOnce(this); Version = _dte.Version; }); }
public VSSolutionManager() { _dte = ServiceLocator.GetInstance <DTE>(); _vsSolution = ServiceLocator.GetGlobalService <SVsSolution, IVsSolution>(); _vsMonitorSelection = ServiceLocator.GetGlobalService <SVsShellMonitorSelection, IVsMonitorSelection>(); // Keep a reference to SolutionEvents so that it doesn't get GC'ed. Otherwise, we won't receive events. _solutionEvents = _dte.Events.SolutionEvents; // can be null in unit tests if (_vsMonitorSelection != null) { Guid solutionLoadedGuid = VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_guid; _vsMonitorSelection.GetCmdUIContextCookie(ref solutionLoadedGuid, out _solutionLoadedUICookie); uint cookie; int hr = _vsMonitorSelection.AdviseSelectionEvents(this, out cookie); ErrorHandler.ThrowOnFailure(hr); } // Allow this constructor to be invoked from either the UI or a worker thread. This JTF call should be // cheap (minimal context switch cost) when we are already on the UI thread. ThreadHelper.JoinableTaskFactory.Run(async delegate { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); UserAgent.SetUserAgentString( new UserAgentStringBuilder().WithVisualStudioSKU(VSVersionHelper.GetFullVsVersionString())); }); _solutionEvents.BeforeClosing += OnBeforeClosing; _solutionEvents.AfterClosing += OnAfterClosing; _solutionEvents.ProjectAdded += OnEnvDTEProjectAdded; _solutionEvents.ProjectRemoved += OnEnvDTEProjectRemoved; _solutionEvents.ProjectRenamed += OnEnvDTEProjectRenamed; var vSStd97CmdIDGUID = VSConstants.GUID_VSStandardCommandSet97.ToString("B"); var solutionSaveID = (int)VSConstants.VSStd97CmdID.SaveSolution; var solutionSaveAsID = (int)VSConstants.VSStd97CmdID.SaveSolutionAs; _solutionSaveEvent = _dte.Events.CommandEvents[vSStd97CmdIDGUID, solutionSaveID]; _solutionSaveAsEvent = _dte.Events.CommandEvents[vSStd97CmdIDGUID, solutionSaveAsID]; _solutionSaveEvent.BeforeExecute += SolutionSaveAs_BeforeExecute; _solutionSaveEvent.AfterExecute += SolutionSaveAs_AfterExecute; _solutionSaveAsEvent.BeforeExecute += SolutionSaveAs_BeforeExecute; _solutionSaveAsEvent.AfterExecute += SolutionSaveAs_AfterExecute; }
public static VsHierarchyItem GetHierarchyItemForProject(Project project) { Debug.Assert(ThreadHelper.CheckAccess()); IVsHierarchy hierarchy; // Get the solution IVsSolution solution = ServiceLocator.GetGlobalService <SVsSolution, IVsSolution>(); int hr = solution.GetProjectOfUniqueName(EnvDTEProjectUtility.GetUniqueName(project), out hierarchy); if (hr != VSConstants.S_OK) { Marshal.ThrowExceptionForHR(hr); } return(new VsHierarchyItem(hierarchy)); }
public VSSolutionManager() { _dte = ServiceLocator.GetInstance <DTE>(); _vsSolution = ServiceLocator.GetGlobalService <SVsSolution, IVsSolution>(); _vsMonitorSelection = ServiceLocator.GetGlobalService <SVsShellMonitorSelection, IVsMonitorSelection>(); // Keep a reference to SolutionEvents so that it doesn't get GC'ed. Otherwise, we won't receive events. _solutionEvents = _dte.Events.SolutionEvents; // can be null in unit tests if (_vsMonitorSelection != null) { Guid solutionLoadedGuid = VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_guid; _vsMonitorSelection.GetCmdUIContextCookie(ref solutionLoadedGuid, out _solutionLoadedUICookie); uint cookie; int hr = _vsMonitorSelection.AdviseSelectionEvents(this, out cookie); ErrorHandler.ThrowOnFailure(hr); } UserAgent.SetUserAgentString( new UserAgentStringBuilder().WithVisualStudioSKU(VSVersionHelper.GetFullVsVersionString())); _solutionEvents.BeforeClosing += OnBeforeClosing; _solutionEvents.AfterClosing += OnAfterClosing; _solutionEvents.ProjectAdded += OnEnvDTEProjectAdded; _solutionEvents.ProjectRemoved += OnEnvDTEProjectRemoved; _solutionEvents.ProjectRenamed += OnEnvDTEProjectRenamed; var vSStd97CmdIDGUID = VSConstants.GUID_VSStandardCommandSet97.ToString("B"); var solutionSaveID = (int)VSConstants.VSStd97CmdID.SaveSolution; var solutionSaveAsID = (int)VSConstants.VSStd97CmdID.SaveSolutionAs; _solutionSaveEvent = _dte.Events.CommandEvents[vSStd97CmdIDGUID, solutionSaveID]; _solutionSaveAsEvent = _dte.Events.CommandEvents[vSStd97CmdIDGUID, solutionSaveAsID]; _solutionSaveEvent.BeforeExecute += SolutionSaveAs_BeforeExecute; _solutionSaveEvent.AfterExecute += SolutionSaveAs_AfterExecute; _solutionSaveAsEvent.BeforeExecute += SolutionSaveAs_BeforeExecute; _solutionSaveAsEvent.AfterExecute += SolutionSaveAs_AfterExecute; }
public OptionsPageActivator() : this(ServiceLocator.GetGlobalService <SVsUIShell, IVsUIShell>()) { }
public VSSourceControlManagerProvider() : this(ServiceLocator.GetInstance <DTE>(), ServiceLocator.GetGlobalService <SComponentModel, IComponentModel>()) { }
public VsSourceControlTracker(ISolutionManager solutionManager, ISourceControlManagerProvider sourceControlManagerProvider, ISettings vsSettings) : this(solutionManager, sourceControlManagerProvider, ServiceLocator.GetGlobalService <SVsTrackProjectDocuments, IVsTrackProjectDocuments2>(), vsSettings) { }