Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@202 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
7 changed files with 131 additions and 58 deletions
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
using DebuggerInterop.Core; |
||||
|
||||
namespace DebuggerLibrary |
||||
{ |
||||
public partial class NDebugger |
||||
{ |
||||
List<Process> processCollection = new List<Process>(); |
||||
|
||||
Process currentProcess; |
||||
|
||||
public event ProcessEventHandler ProcessStarted; |
||||
public event ProcessEventHandler ProcessExited; |
||||
|
||||
public Process CurrentProcess { |
||||
get { |
||||
if (currentProcess == null && Processes.Count > 0) { |
||||
currentProcess = Processes[0]; |
||||
} |
||||
return currentProcess; |
||||
} |
||||
set { |
||||
currentProcess = value; |
||||
} |
||||
} |
||||
|
||||
public IList<Process> Processes { |
||||
get { |
||||
return processCollection.AsReadOnly(); |
||||
} |
||||
} |
||||
|
||||
internal Process GetProcess(ICorDebugProcess corProcess) |
||||
{ |
||||
foreach (Process process in Processes) { |
||||
if (process.CorProcess == corProcess) { |
||||
return process; |
||||
} |
||||
} |
||||
throw new DebuggerException("Process not found"); |
||||
} |
||||
|
||||
internal void AddProcess(Process process) |
||||
{ |
||||
processCollection.Add(process); |
||||
OnProcessStarted(process); |
||||
} |
||||
|
||||
internal void RemoveProcess(Process process) |
||||
{ |
||||
processCollection.Remove(process); |
||||
OnProcessExited(process); |
||||
} |
||||
|
||||
protected virtual void OnProcessStarted(Process process) |
||||
{ |
||||
if (ProcessStarted != null) { |
||||
ProcessStarted(this, new ProcessEventArgs(process)); |
||||
} |
||||
} |
||||
|
||||
protected virtual void OnProcessExited(Process process) |
||||
{ |
||||
if (ProcessExited != null) { |
||||
ProcessExited(this, new ProcessEventArgs(process)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
// <file>
|
||||
// <owner name="David Srbecký" email="dsrbecky@post.cz"/>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace DebuggerLibrary |
||||
{ |
||||
public delegate void ProcessEventHandler (object sender, ProcessEventArgs args); |
||||
|
||||
[Serializable] |
||||
public class ProcessEventArgs: EventArgs |
||||
{ |
||||
Process process; |
||||
|
||||
public Process Process { |
||||
get { |
||||
return process; |
||||
} |
||||
} |
||||
|
||||
public ProcessEventArgs(Process process) |
||||
{ |
||||
this.process = process; |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue