Closed harrison314 closed 5 years ago
Add method for IInvocation to call method on another context:
IInvocation
interface IExample { int Call(int x); } class ContextutalExample :IExample, IDisposable { public int Call(int x) { return x+1; } public void Dispose() { } } ProxyGenerator generator = new ProxyGenerator(); InterceptorAdapter adapter = new InterceptorAdapter(invocation => { using(ContextutalExample instance = new ContextutalExample()) { invocation.Process(instance); } }); IExample proxy = generator.GenerateProxy<IExample>(adapter);
See MethodBuilder ImplementParentCallMethod(TypeBuilder typeBuilder, Type interfaceType, MethodInfo originalMethod)
MethodBuilder ImplementParentCallMethod(TypeBuilder typeBuilder, Type interfaceType, MethodInfo originalMethod)
Add method for
IInvocation
to call method on another context: