diff options
| author | Jean-Philippe Bruyère <jp_bruyere@hotmail.com> | 2020-02-11 10:49:09 +0100 |
|---|---|---|
| committer | j-p <jp_bruyere@hotmail.com> | 2020-05-10 00:50:02 +0200 |
| commit | 701e6c825abbfb431bda3f6692e32a5f12e7307b (patch) | |
| tree | 6cfc0e63453fd235dfe81967094c3357a692c67b /Samples/HelloWorld/main.cs | |
| parent | 2774a37e0a20412971e17571e152768b299318db (diff) | |
wip
Diffstat (limited to 'Samples/HelloWorld/main.cs')
| -rw-r--r-- | Samples/HelloWorld/main.cs | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Samples/HelloWorld/main.cs b/Samples/HelloWorld/main.cs index 14a1a2ad..c407b04e 100644 --- a/Samples/HelloWorld/main.cs +++ b/Samples/HelloWorld/main.cs @@ -1,5 +1,9 @@ using System; +using System.Linq; +using System.Reflection; +using System.Reflection.Emit; using Crow; +using Crow.IML; namespace HelloWorld { @@ -10,6 +14,7 @@ namespace HelloWorld vke.Run (); } } + protected override void Startup () { CMDQuit = new Command (new Action (() => running = false)) { Caption = "Quit", Icon = new SvgPicture ("#Crow.Icons.exit-symbol.svg") }; @@ -19,6 +24,17 @@ namespace HelloWorld w.DataSource = this; } + public SolidColor testColor = Color.Red; + public SolidColor TestColor { + get => testColor; + set { + if (testColor == value) + return; + testColor = value; + NotifyValueChanged ("TestColor", testColor); + } + } + Color [] colors = { Color.Blue, Color.DarkGoldenRod, Color.Red, Color.Azure, Color.Brown, Color.Black, Color.White, Color.Pink }; int ptr = 0; @@ -37,6 +53,48 @@ namespace HelloWorld if (ptr == colors.Length) ptr = 0; } + public override bool OnKeyDown (Key key) + { + switch (key) { + case Key.d: + dump (); + break; + case Key.space: + TestColor = Color.Green; + break; + default: + return base.OnKeyDown (key); + } + return true; + } + + void dump () + { + Instantiator inst = Instantiators ["#HelloWorld.helloworld.crow"]; + + foreach (Delegate cd in inst.CachedDelegates) { + FieldInfo mb = typeof(Delegate).GetField("original_method_info", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField); + + DynamicMethod dynMethod = mb.GetValue (cd) as DynamicMethod; + /*Console.WriteLine (typeof (ILGenerator).GetFields (BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.GetField)); + + var ilgen = dynMethod.GetILGenerator (); + + + +*/ + + MethodBody body = dynMethod.GetMethodBody (); + + byte [] il = body.GetILAsByteArray (); + foreach (byte b in il) { + Console.Write ($"{b:x2} "); + //Console.WriteLine (b); + } + + } + + } } } |