| 1 |
using System; |
| 2 |
using System.IO; |
| 3 |
using System.Diagnostics; |
| 4 |
using System.Linq; |
| 5 |
|
| 6 |
using Mono.Cecil.Mdb; |
| 7 |
|
| 8 |
namespace Mono.Cecil.Debug { |
| 9 |
|
| 10 |
interface IFoo { } |
| 11 |
interface IBar : IFoo { } |
| 12 |
|
| 13 |
abstract class Bar : IBar { } |
| 14 |
|
| 15 |
delegate void Action (); |
| 16 |
|
| 17 |
class Program { |
| 18 |
|
| 19 |
static int Answer () |
| 20 |
{ |
| 21 |
return 42; |
| 22 |
} |
| 23 |
|
| 24 |
static void Main (string [] args) |
| 25 |
{ |
| 26 |
Time (() => { |
| 27 |
var module = GetCurrentModule (); |
| 28 |
|
| 29 |
module.Write ("dbg.rt.exe"); |
| 30 |
}); |
| 31 |
} |
| 32 |
|
| 33 |
static void Time (Action action) |
| 34 |
{ |
| 35 |
var watch = new Stopwatch (); |
| 36 |
watch.Start (); |
| 37 |
action (); |
| 38 |
watch.Stop (); |
| 39 |
|
| 40 |
Console.WriteLine ("Elapsed: {0}", watch.Elapsed); |
| 41 |
} |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
static ModuleDefinition GetModule (string module) |
| 49 |
{ |
| 50 |
return ModuleDefinition.ReadModule (module, new ReaderParameters { |
| 51 |
ReadingMode = ReadingMode.Deferred, |
| 52 |
}); |
| 53 |
} |
| 54 |
|
| 55 |
static ModuleDefinition GetCurrentModule () |
| 56 |
{ |
| 57 |
return GetModule (typeof (object).Module.FullyQualifiedName); |
| 58 |
} |
| 59 |
} |
| 60 |
} |