0

Currently I'm trying to reimplement some code code written in Castle Windsor in structuremap.

This code:

Component.For(typeof(IMongoCollection<>))
  .UsingFactoryMethod(
   (k, c) => MongoResolver.ResolveCollection(k, c.RequestedType)));

Does the following: When IMongoCollection is being called, resolve the concrete collection.

I tried to do this in structuremap with:

For(typeof(IMongoCollection<>)).Use("test", x =>
{
     SOME MAGIC!
}); 

But I cant figure out what to do in the magic part.

Patrick
  • 2,730
  • 4
  • 33
  • 55
  • Something like this question? http://stackoverflow.com/questions/10671078/registering-method-on-generic-factory-with-structuremap – Tieson T. Feb 14 '17 at 21:27
  • Not completely, but this link set me onto a trail that led me to https://github.com/structuremap/structuremap/blob/977b1784632484473d09d3724f2435a73437e49b/src/StructureMap.Testing/Acceptance/builder_for_open_generic_type.cs And that fixed it. – Patrick Feb 14 '17 at 22:00
  • 2
    Consider adding a self-answer? – Tieson T. Feb 14 '17 at 22:22

0 Answers0