开发者

Is there a way to have structmap inject an array of all implementations of an interface?

Example

MyConstruction(IEnumberable<IMyInterface> myInterfaces)
{
}

where I have a couple of classes that implemen开发者_开发技巧t IMyInterface.


You don't have to declare them explicitly. Take advantage of the scanning feature:

Scan(x =>
{
    x.TheCallingAssembly(); // or specify additional assemblies to scan

    x.AddAllTypesOf<IMyInterface>();
});


I actually found a blog post describing this issue. It isn't exactly what I was looking for because I would rather not have to explicitly list the implementations.

http://www.lostechies.com/blogs/jimmy_bogard/archive/2008/09/03/building-arrays-in-structuremap-2-5.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜