JasperFx / lamar

Fast Inversion of Control Tool and Successor to StructureMap
https://jasperfx.github.io/lamar
MIT License
572 stars 119 forks source link

Add support for open generics and lambdas #128

Closed silkfire closed 5 years ago

silkfire commented 5 years ago

This used to work in StructureMap, but unfortunately not in Lamar:

 For(typeof(IShipmentRepository<,>))
.Add(() => new Data.Json.Repositories.ShipmentRepository(shipmentDataFilepaths))
.Scoped();

The Add method has no lambda overload. Am I missing something or has this simply been overlooked?

jeremydmiller commented 5 years ago

@silkfire I think that's something that only worked accidentally in StructureMap. This isn't something that I'd want to support or I think would be very universally usable. In the rare case where you want to automatically close an open type without also using a concrete open type, I'd recommend using a custom Instance that has its own implementation of CloseType(). That or you could get this done with an IFamilyPolicy that does this lazily.

jeremydmiller commented 5 years ago

The reporter has moved on to a different tool and this isn't something that's really possible to support anyway.