Is interception of interfaces methods supported?

Nov 25, 2013 at 8:21 AM
Edited Nov 25, 2013 at 8:28 AM
I have have IMyInterface with method void Do() . I have implementation of this interface MyInterface . Interface and implementation are in external thirdparty lib. I want to generate MyInterfacesWrapper which implements void Do() (and all other methods of interfaces) in next way:
public class MyInterfacesWrapper:IMyInterface{
private MyInterface _impl;
public MyInterfacesWrapper(MyInterface impl){
  _impl = impl;
}

public void Do(){
   _impl.Do();
}
}
Interfaces has many methods I would like to automate wrapping.
I cannot use RealProxy (because have to use reflection invocation which is forbidden in my case).
I have not tried Unity. Iterception (if it uses reflection to invoke member that it is unacceptable, and also I do not want to depend upon Unity libs and slow down start up because of runtime codegen).
Would be great that if SheepAspect supports such wrapping it also support elimination of all dependency on SheepAspect libs after build.


My final solution could go to writing something manually using Mono.Cecil if not found good way..
I need this because cannot call COM IUnknown(no reflection invocation supported) from IronPython, hence will generate C# wrapper which does calls and is reflected.