How to use code generation to dynamically create C# methods?

后端 未结 4 1182
忘了有多久
忘了有多久 2021-02-05 17:11

In order to define a method in C that is callable by Lua it has to match a given signature and use the Lua API to retrieve parameters and return results. I\'m writing a C# wrapp

4条回答
  •  面向向阳花
    2021-02-05 17:53

    I'm not sure that I'm interpreting your question correctly but you might want to have a look at Castle.Dynamic proxy. It allows you to create proxies for classes and interfaces and then intercept certain method calls (anything at all on an interface and anything virtual on a real class). When you intercept the call you can just look at the arguments and forward the call to the lua API via P-Invoke. There's a great tutorial here.

提交回复
热议问题