温莎城堡登记流利 - 什么是选择()呢? [英] Castle Windsor Fluent Registration - What does Pick() do?

查看:138
本文介绍了温莎城堡登记流利 - 什么是选择()呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用自动登记温莎城堡我看到人们做这样的事情。

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

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

有关我的生活,我不能找出匹克()方法做什么我也不能找到任何文件。谁能解释一下?

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?

推荐答案

选择(IEnumerable的<类型>) 的同义词从(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&LT;对象&gt;(),所以它有效地选择所有的类型。

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)

像往常一样,看看在流利的API维基并/或<一个href=\"http://svn.castleproject.org:8080/svn/castle/trunk/InversionOfControl/Castle.MicroKernel.Tests/Registration/AllTypesTestCase.cs\"相对=nofollow>测试案例了解详情。

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

这篇关于温莎城堡登记流利 - 什么是选择()呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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