Mixing Dynamic code with non-dynamic code.
-
Hi all, I'm writing some code that I want to be part user generated part auto generated. The code will be C# but used as a script through embedding Mono in a c++ application. Ideally I want my users to use a graphical editor that will auto-generate the class and the constructor using info from the editor(I've done this using the AssemblyBuilder and Reflection.Emit) But then I want the user to be able to use a text editor to write an override for the Update() method then any number of public or private methods they wish to define. I want to be able to compile this hand-writen code (I'm doing this with the CSharpCodeProvider) but I want to inject it into the autogenerated code some how. So the class and constructor is auto-generated and the Update method and any number of other methods are handwritten in C# 2.0 and the results combined into a single dll. I hope this explanation makes sense.... can any one help? Thanks.
-
Hi all, I'm writing some code that I want to be part user generated part auto generated. The code will be C# but used as a script through embedding Mono in a c++ application. Ideally I want my users to use a graphical editor that will auto-generate the class and the constructor using info from the editor(I've done this using the AssemblyBuilder and Reflection.Emit) But then I want the user to be able to use a text editor to write an override for the Update() method then any number of public or private methods they wish to define. I want to be able to compile this hand-writen code (I'm doing this with the CSharpCodeProvider) but I want to inject it into the autogenerated code some how. So the class and constructor is auto-generated and the Update method and any number of other methods are handwritten in C# 2.0 and the results combined into a single dll. I hope this explanation makes sense.... can any one help? Thanks.
It seems like all of the code is dynamic. If the result is a single dll, then you can combine all code (text) right before compilation. If the result is two dlls or more, you can create an interface and then load the implementation of Update on runtime (there are many other ways...)