I want to add some behavior to a certain class at runtime. I know how to subclass at runtime using Reflection.Emit but thats not enough, Depending on some external configuration I need to inject opcodes in a method on a type T so all classes that inherit from it automatically gain this behavior.(I cant use the .NET Profiling API)
Can something like this be done with Mono.Cecil?
If it isnt possible to modify code on a loaded assembly, It is fine If I can make the modifications before the assembly is loaded and then load the modified assembly in memory, but I dont know how I can control assembly loading.