forked from CosmosOS/Cosmos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DebugCommandHandler.cs
70 lines (62 loc) · 2.46 KB
/
DebugCommandHandler.cs
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.OLE.Interop;
using IServiceProvider = System.IServiceProvider;
namespace Cosmos.VS.DebugEngine.Commands
{
public delegate int DebugCommandExecute(uint nCmdExecOpt, IntPtr pvaIn, IntPtr pvaOut);
public class DebugCommandHandler
{
public DebugCommandHandler(IServiceProvider serviceProvider)
{
var launchCommand = new DebugLaunchCommand(serviceProvider);
OnDebugLaunch += launchCommand.Execute;
var logCommand = new DebugLogCommand(serviceProvider);
OnDebugLog += logCommand.Execute;
var execCommand = new DebugExecCommand(serviceProvider);
OnDebugExec += execCommand.Execute;
}
public event DebugCommandExecute OnDebugLaunch;
public event DebugCommandExecute OnDebugExec;
public event DebugCommandExecute OnDebugLog;
public int Execute(uint nCmdID, uint nCmdExecOpt, IntPtr pvaIn, IntPtr pvaOut)
{
switch (nCmdID)
{
case CmdIDList.DebugLaunchCmdID:
if (OnDebugLaunch != null)
{
return OnDebugLaunch(nCmdExecOpt, pvaIn, pvaOut);
}
break;
case CmdIDList.DebugExecCmdID:
if (OnDebugExec != null)
{
return OnDebugExec(nCmdExecOpt, pvaIn, pvaOut);
}
break;
case CmdIDList.DebugLogCmdID:
if (OnDebugLog != null)
{
return OnDebugLog(nCmdExecOpt, pvaIn, pvaOut);
}
break;
}
global::System.Diagnostics.Debug.Fail("Unknown command id");
return VSConstants.E_NOTIMPL;
}
public int Query(uint cCmds, OLECMD[] prgCmds, IntPtr pCmdText)
{
switch (prgCmds[0].cmdID)
{
case CmdIDList.DebugLaunchCmdID:
case CmdIDList.DebugExecCmdID:
case CmdIDList.DebugLogCmdID:
prgCmds[0].cmdf |= (uint)(OLECMDF.OLECMDF_SUPPORTED | OLECMDF.OLECMDF_ENABLED | OLECMDF.OLECMDF_INVISIBLE);
return VSConstants.S_OK;
}
global::System.Diagnostics.Debug.Fail("Unknown command id");
return VSConstants.E_NOTIMPL;
}
}
}