3

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.

George Mauer
  • 117,483
  • 131
  • 382
  • 612

1 Answers1

3

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

Krzysztof Kozmic
  • 27,267
  • 12
  • 73
  • 115