gpt4 book ai didi

c# - 使用 'where' 谓词从 Windsor CaSTLe 中的 Assembly 注册类型

转载 作者:行者123 更新时间:2023-12-01 23:16:32 24 4
gpt4 key购买 nike

我很困惑如何实现满足以下条件的注册:

  1. 来自当前程序集
  2. 公共(public) + 非公共(public)类型
  3. 与 TInterface 相同的命名空间
  4. 所有服务和自助
  5. 类型应以“适配器”结尾

我使用以下方法,但我不明白 where put 'where' type is 子句:

private BasedOnDescriptor CreateDescriptor<TInterface>(Predicate<Type> accepted)
{
return Classes
.FromAssemblyContaining<TInterface>()
.IncludeNonPublicTypes()
.Where(Component.IsInSameNamespaceAs<TInterface>())
.WithService.AllInterfaces()
.WithService.Self();
}

“accepted”子句应该指出应该使用什么类型名称谢谢。

最佳答案

.If(t => t.Name.EndsWith("适配器"))

但是,抛开如何不谈,为了架构的清晰性,将类型分离到它们自己的命名空间中可能是一个好主意。副作用是,您不需要额外的过滤谓词。

关于c# - 使用 'where' 谓词从 Windsor CaSTLe 中的 Assembly 注册类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26125808/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com