-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDteInitializer.cs
More file actions
40 lines (37 loc) · 1.15 KB
/
DteInitializer.cs
File metadata and controls
40 lines (37 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell.Interop;
namespace BetterConfigurationManager
{
/// <summary>
/// http://www.mztools.com/articles/2013/MZ2013029.aspx
/// </summary>
internal class DteInitializer : IVsShellPropertyEvents
{
internal DteInitializer(IVsShell shellService, Action callback)
{
this.shellService = shellService;
this.callback = callback;
// Set an event handler to detect when the IDE is fully initialized
int hr = this.shellService.AdviseShellPropertyChanges(this, out cookie);
ErrorHandler.ThrowOnFailure(hr);
}
private readonly IVsShell shellService;
private readonly Action callback;
private uint cookie;
int IVsShellPropertyEvents.OnShellPropertyChange(int propId, object var)
{
if (propId != (int)__VSSPROPID.VSSPROPID_Zombie)
return VSConstants.S_OK;
var isZombie = (bool)var;
if (isZombie)
return VSConstants.S_OK;
// Release the event handler to detect when the IDE is fully initialized
int hr = shellService.UnadviseShellPropertyChanges(cookie);
ErrorHandler.ThrowOnFailure(hr);
cookie = 0;
callback();
return VSConstants.S_OK;
}
}
}