Castle Windsor Fluent Registration - Pick() 有什么作用? [英] Castle Windsor Fluent Registration - What does Pick() do?

查看:35
本文介绍了Castle Windsor Fluent Registration - Pick() 有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在城堡温莎使用自动注册时,我看到人们在做类似的事情

When using auto-registration with castle windsor I see people doing things like

_container.Register(
  AllTypes.Pick().FromAssembly(Assembly.GetExecutingAssembly())
    .WithService.FirstInterface());

在我的一生中,我无法弄清楚 Pick() 方法的作用,也找不到任何文档.谁能给我解释一下?

For the life of me I can't figure out what the Pick() method does nor can I find any documentation. Can anyone explain it to me?

推荐答案

Pick(IEnumerable) From(IEnumerable) 的同义词,即选择指定的类型作为注册目标.

Pick(IEnumerable<Type>) is a synonym for From(IEnumerable<Type>), i.e. it selects the specified types as registration targets.

AllTypes.Pick() AllTypes.Of<object>() 相同,因此它有效地选择了所有类型.

AllTypes.Pick() is the same as AllTypes.Of<object>(), so it effectively selects all types.

AllTypes.Pick().FromAssembly(Assembly.GetExecutingAssembly()) 将选择正在执行的程序集中的所有类型(然后你当然可以过滤)

AllTypes.Pick().FromAssembly(Assembly.GetExecutingAssembly()) will select ALL types in the executing assembly (you can then filter, of course)

像往常一样,查看 fluent API wiki 和/or 测试用例 了解更多信息.

As usual, take a look at the fluent API wiki and/or test case for more information.

这篇关于Castle Windsor Fluent Registration - Pick() 有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆