George Mauer
George Mauer

Reputation: 122062

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.

Upvotes: 3

Views: 892

Answers (1)

Krzysztof Kozmic
Krzysztof Kozmic

Reputation: 27374

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

Upvotes: 3

Related Questions