jeudi 3 juin 2021

What is the best method to create event handler function code at run time?

I would like to store the function commands in a table. When populating the form at run time with dynamic objects. I would like the event functions of the objects to be created using the commands stored in the table.

Thanks to @jmcilhinney solution, which used reflection, to my first question, "Create event handles dynamically using variable actions"

I did some research into reflection and have found that it can be done using Reflection.Emit, however, the code has to be complied/written in MSIL op code. I must admit it looks a lot like assembler, which I have not used in decades!

I also looked at CodeDOM but I am not sure if that would work.

Further questions:

  1. Is there a compiler that can be called at run time to create MSIL op code? If yes, then reflection emit would work.
  2. Is there a better solution than reflection emit?
  3. Would a combination of CodeDOM and reflection emit not work?




Aucun commentaire:

Enregistrer un commentaire