PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/dbg/Program.cs

http://github.com/jbevain/cecil
C# | 60 lines | 42 code | 14 blank | 4 comment | 0 complexity | d6a6e6e17c7efe804028c1e6f628a8c8 MD5 | raw file
 1using System;
 2using System.IO;
 3using System.Diagnostics;
 4using System.Linq;
 5
 6using Mono.Cecil.Mdb;
 7
 8namespace 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		//static TypeDefinition GetCurrentType ()
44		//{
45		//    return GetCurrentModule ().Types [typeof (Program).FullName];
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}