簡體   English   中英

使用“ where”謂詞在溫莎城堡中的程序集中注冊類型

[英]Register types from Assembly in Windsor Castle with 'where' predicate

我對如何實現滿足以下條件的注冊感到困惑:

  1. 從當前組裝
  2. 公共+非公共類型
  3. 與TInterface相同的名稱空間
  4. 所有服務和自我
  5. 類型應以“ adapter”結尾

我使用以下方法,但是我不明白在哪里放置“ where”類型是子句:

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("Adapter"))

然而,把如何不談,它可能是類型分成自己的命名空間,用於建築的清晰度是一個好主意。 副作用是,您不需要額外的過濾謂詞。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM