Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Api Castle Windsor Fluent注册-Pick()做什么?_Api_Castle Windsor_Fluent Interface - Fatal编程技术网

Api Castle Windsor Fluent注册-Pick()做什么?

Api Castle Windsor Fluent注册-Pick()做什么?,api,castle-windsor,fluent-interface,Api,Castle Windsor,Fluent Interface,当使用castle windsor的自动注册时,我看到人们在做类似的事情 _container.Register( AllTypes.Pick().FromAssembly(Assembly.GetExecutingAssembly()) .WithService.FirstInterface()); 就我的一生而言,我不知道Pick()方法做什么,也找不到任何文档。有人能给我解释一下吗?从(IEnumerable)中选择(IEnumerable),也就是说,它选择指定的类型作为注

当使用castle windsor的自动注册时,我看到人们在做类似的事情

_container.Register(
  AllTypes.Pick().FromAssembly(Assembly.GetExecutingAssembly())
    .WithService.FirstInterface());
就我的一生而言,我不知道Pick()方法做什么,也找不到任何文档。有人能给我解释一下吗?

从(IEnumerable)
中选择(IEnumerable)
,也就是说,它选择指定的类型作为注册目标

AllTypes.Pick()
AllTypes.Of()
,因此它可以有效地选择所有类型

AllTypes.Pick().fromsassembly(Assembly.getExecutionGassembly())
将选择正在执行的程序集中的所有类型(当然,您可以过滤)


像往常一样,查看和/或以获取更多信息。

这是这个fluent API中选择哪些类型将自动注册到容器中的起点

Container.Register(
        AllTypes.Pick()
        .FromAssemblyNamed("MyAssembly")
        .If(t => t.Name.EndsWith("ABC"))
        .Configure(c => c.LifeStyle.Is(LifestyleType.Transient))
        .WithService.Select(i => typeof(I))
    );
在本例中,从MyAssembly中选择的名称以“ABC”结尾的所有类型都将作为类型I的服务添加到具有临时生活方式的容器中


这是一种内部DSL形式的声明性方法。使用这种API,方法用于对稍后执行的行为进行排序配置。为了实现这一点,这些方法返回构建器,指导配置的各个步骤,而实际工作在最后完成。

问题在于,在上面的示例中,似乎没有使用AllTypes.Pick().FromAssemblyNamed(…)。如果(…)可以使用更短、更标准化的AllTypes.FromAssemblyNamed(…)。Where(…)Mausch-你有没有想过为Castle docs提供关于fluent Interce的内容?这不是你回答的第一个问题。