开发者

Structuremap Generics with two type parameters

开发者 https://www.devze.com 2023-01-06 19:20 出处:网络
I know I can, in Structuremap, do thi开发者_开发技巧s: var container = new Container(cfg => {

I know I can, in Structuremap, do thi开发者_开发技巧s:

var container = new Container(cfg =>
{
    cfg.For(typeof (IDomainDataRepository<>)).Use(typeof (DomainDataRepository<>));
});

but what if my Interface has 2 type parameters:

IDomainDataRepository<T,TKey> instead ofIDomainDataRepository<T>

How to tell Structuremap to instantiate this type of classes?


Ok, I figured it out.

var container = new Container(cfg =>
{
    cfg.For(typeof(IDomainDataRepository<,>)).Use(typeof(DomainDataRepository<,>));
});
0

精彩评论

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