Skip to content

Commit 2acbfc9

Browse files
Merge pull request #320 from Hefaistos68/master
added a few additional interfaces/services
2 parents edac116 + d028cf9 commit 2acbfc9

File tree

2 files changed

+85
-1
lines changed

2 files changed

+85
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,5 @@ paket-files/
259259

260260
# Python Tools for Visual Studio (PTVS)
261261
__pycache__/
262-
*.pyc
262+
*.pyc
263+
/src/toolkit/Community.VisualStudio.Toolkit.Shared/.vshistory/Services.cs

src/toolkit/Community.VisualStudio.Toolkit.Shared/Services.cs

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Threading.Tasks;
44
using Microsoft.VisualStudio.ComponentModelHost;
55
using Microsoft.VisualStudio.Editor;
6+
using Microsoft.VisualStudio.OLE.Interop;
67
using Microsoft.VisualStudio.Shell.Interop;
78
#if VS16 || VS17
89
using Microsoft.VisualStudio.TaskStatusCenter;
@@ -19,11 +20,38 @@ public class Services
1920
internal Services()
2021
{ }
2122

23+
#region Object Manager
24+
/// <summary>
25+
/// Performs a search for a specified object. The environment implements the interface
26+
/// </summary>
27+
public Task<IVsObjectSearch> GetFindSymbolAsync() => VS.GetRequiredServiceAsync<SVsObjectSearch, IVsObjectSearch>();
28+
#endregion
29+
30+
/// <summary>
31+
/// Controls the binding between keys and commands
32+
/// </summary>
33+
public Task<IVsFilterKeys> GetFilterKeysAsync() => VS.GetRequiredServiceAsync<SVsFilterKeys, IVsFilterKeys>();
34+
2235
#region Selection
2336
/// <summary>
2437
/// Provides access to the selection API.
2538
/// </summary>
2639
public Task<IVsMonitorSelection> GetMonitorSelectionAsync() => VS.GetRequiredServiceAsync<SVsShellMonitorSelection, IVsMonitorSelection>();
40+
41+
/// <summary>
42+
/// Creates a new context or subcontext bag
43+
/// </summary>
44+
public Task<IVsMonitorUserContext> GetMonitorUserContextAsync() => VS.GetRequiredServiceAsync<SVsMonitorUserContext, IVsMonitorUserContext>();
45+
46+
/// <summary>
47+
/// This interface is used by a package to register and un-register its library manager with the object manager
48+
/// </summary>
49+
public Task<IVsObjectManager> GetObjectManagerAsync() => VS.GetRequiredServiceAsync<SVsObjectManager, IVsObjectManager>();
50+
51+
/// <summary>
52+
/// Used by a VSPackage to register and unregister the symbol libraries with the Visual Studio object manager and create component sets that can be browsed
53+
/// </summary>
54+
public Task<IVsObjectManager2> GetObjectManager2Async() => VS.GetRequiredServiceAsync<SVsObjectManager, IVsObjectManager2>();
2755
#endregion
2856

2957
#region Solution
@@ -36,15 +64,35 @@ internal Services()
3664
/// Opens a Solution or Project using the standard open dialog boxes.
3765
/// </summary>
3866
public Task<IVsOpenProjectOrSolutionDlg> GetOpenProjectOrSolutionDlgAsync() => VS.GetRequiredServiceAsync<SVsOpenProjectOrSolutionDlg, IVsOpenProjectOrSolutionDlg>();
67+
68+
69+
/// <summary>
70+
/// Gives access to the solution hierarchy and properties
71+
/// </summary>
72+
public Task<IVsHierarchy> GetSolutionHierarchyAsync() => VS.GetRequiredServiceAsync<SVsSolution, IVsHierarchy>();
73+
74+
/// <summary>
75+
/// Gives access to the solution and properties persistence
76+
/// </summary>
77+
public Task<IVsSolutionPersistence> GetSolutionPersistenceAsync() => VS.GetRequiredServiceAsync<SVsSolutionPersistence, IVsSolutionPersistence>();
3978
#endregion
4079

4180
#region Shell
4281
/// <summary>Provides access to the fundamental environment services, specifically those dealing with VSPackages and the registry.</summary>
4382
public Task<IVsShell> GetShellAsync() => VS.GetRequiredServiceAsync<SVsShell, IVsShell>();
4483

84+
/// <summary>Provides access to extra VSPackage functionality</summary>
85+
public Task<IVsShell5> GetShell5Async() => VS.GetRequiredServiceAsync<SVsShell, IVsShell5>();
86+
4587
/// <summary>This interface provides access to basic windowing functionality, including access to and creation of tool windows and document windows.</summary>
4688
public Task<IVsUIShell> GetUIShellAsync() => VS.GetRequiredServiceAsync<SVsUIShell, IVsUIShell>();
4789

90+
/// <summary>This interface provides access to additional toolbar methods</summary>
91+
public Task<IVsUIShell4> GetUIShell4Async() => VS.GetRequiredServiceAsync<SVsUIShell, IVsUIShell4>();
92+
93+
/// <summary>This interface provides access to additional theme methods and some other stuff</summary>
94+
public Task<IVsUIShell5> GetUIShell5Async() => VS.GetRequiredServiceAsync<SVsUIShell, IVsUIShell5>();
95+
4896
/// <summary>This interface is used by a package to read command-line switches entered by the user.</summary>
4997
public Task<IVsAppCommandLine> GetAppCommandLineAsync() => VS.GetRequiredServiceAsync<SVsAppCommandLine, IVsAppCommandLine>();
5098

@@ -70,6 +118,35 @@ internal Services()
70118

71119
/// <summary>Used to retrieved services defined in the MEF catalog, such as the editor specific services like <see cref="IVsEditorAdaptersFactoryService"/>.</summary>
72120
public Task<IComponentModel2> GetComponentModelAsync() => VS.GetRequiredServiceAsync<SComponentModel, IComponentModel2>();
121+
122+
/// <summary>Defines a component manager, a component that coordinates other components with its message loop for message processing and allocation of idle time</summary>
123+
public Task<IOleComponentManager> GetComponentManagerAsync() => VS.GetRequiredServiceAsync<SOleComponentManager, IOleComponentManager>();
124+
125+
/// <summary>
126+
/// Manages the set of currently open documents in the environment
127+
/// </summary>
128+
public Task<IVsRunningDocumentTable> GetRunningDocumentTableAsync() => VS.GetRequiredServiceAsync<SVsRunningDocumentTable, IVsRunningDocumentTable>();
129+
130+
/// <summary>
131+
/// Loads managed and unmanaged resources from Satellite DLLs.
132+
/// </summary>
133+
public Task<IVsResourceManager> GetResourceManagerAsync() => VS.GetRequiredServiceAsync<SVsResourceManager, IVsResourceManager>();
134+
135+
/// <summary>
136+
/// Controls the state of open documents within the environment
137+
/// </summary>
138+
public Task<IVsUIShellOpenDocument> GetShellOpenDocumentAsync() => VS.GetRequiredServiceAsync<SVsUIShellOpenDocument, IVsUIShellOpenDocument>();
139+
140+
/// <summary>
141+
/// Gives access to preview and viewing status
142+
/// </summary>
143+
public Task<IVsUIShellOpenDocument3> GetShellOpenDocument3Async() => VS.GetRequiredServiceAsync<SVsUIShellOpenDocument, IVsUIShellOpenDocument3>();
144+
145+
/// <summary>Gives access to the task scheduler</summary>
146+
public Task<IVsTaskSchedulerService> GetTaskSchedulerAsync() => VS.GetRequiredServiceAsync<SVsTaskSchedulerService, IVsTaskSchedulerService>();
147+
148+
/// <summary>Gives access to long idle events</summary>
149+
public Task<IVsLongIdleManager> GetLongIdleManagerAsync() => VS.GetRequiredServiceAsync<SVsLongIdleManager, IVsLongIdleManager>();
73150
#endregion
74151

75152
#region Notifications
@@ -124,6 +201,12 @@ internal Services()
124201
/// A service for handling solution builds.
125202
/// </summary>
126203
public Task<IVsSolutionBuildManager> GetSolutionBuildManagerAsync() => VS.GetRequiredServiceAsync<SVsSolutionBuildManager, IVsSolutionBuildManager>();
204+
205+
/// <summary>
206+
/// Gets the error list
207+
/// </summary>
208+
public Task<IVsErrorList> GetErrorListAsync() => VS.GetRequiredServiceAsync<SVsErrorList, IVsErrorList>();
209+
127210
#endregion
128211

129212
#region Windows

0 commit comments

Comments
 (0)