Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create dynamic proxy that implements multiple interfaces simultaneously

I can't quite figure out how to use dynamic proxy how to implement multiple interfaces at the same time. Using a third party library I have something like

interface ISubscribe<T> { Consume(T msg); }

I would like to dynamically create a class that simultaneously implements

ISubscribe<Foo>, ISubscribe<Bar>

and for each one calls Logger.Log(msg) (the type parameter on that is dynamic).

I can't figure out quite how to do this.

like image 376
George Mauer Avatar asked Apr 14 '26 14:04

George Mauer


1 Answers

The proxy creation methods have a Type[] parameter called additionalInterfacesToProxy. Pass all the extra interfaces you want to proxy through there.

like image 116
Krzysztof Kozmic Avatar answered Apr 16 '26 04:04

Krzysztof Kozmic