3

I wonder if it's possible to configure StructureMap to handle proxy class instances as the underlying instance.

My problem is that the CMS I'm using (called Episerver) creates proxy instances of the classes I define, for example MyBlock will be instantiated as a proxy with the type MyBlockProxy. So even though I configure StructureMap to resolve IMyInterface<MyBlock> it fails when I try to resolve an instance of IMyInterface<MyBlockProxy>.

Episerver uses Castle DynamicProxy to generate the proxied instances.

Is it possible to configure StructureMap so that it resolves IMyInterface<MyBlockProxy> in the same way as IMyInterface<MyBlock>?

OriginalUtter
  • 619
  • 3
  • 15
  • 28
  • 2
    Cannot remember exactly but I recall us using `TypeInterceptor` combined with `ProxyGenerator()`, this was, however, a while ago. Now to a more general recommendation - don't put any Page/Blocktypes/Epi contentdata in the container until we get the new framework where replacing StructureMap will (most likely) be possible. Instead, allow epi to resolve its stuff and put your implementation in View and ContentModels where you are in control. – Eric Herlitz Oct 24 '19 at 20:51
  • 2
    Could you describe the scenario, i.e. what you need to accomplish? I haven't come across this as being a problem, so it's probably a pattern I haven't come across. But in general I agree with @EricHerlitz above. :) – Ted Nyberg Oct 31 '19 at 06:33

0 Answers0