C# 在温莎城堡按复杂命名约定注册

C# 在温莎城堡按复杂命名约定注册,c#,dependency-injection,naming-conventions,castle-windsor,auto-registration,C#,Dependency Injection,Naming Conventions,Castle Windsor,Auto Registration,我是DI容器领域的新手。我目前正在使用Windsor Castle,我正试图通过命名约定来配置我的容器。下面是我尝试做的一个例子: interface INode{} interface INodeType1: INode{} interface INodeType2: INode{} interface INodeConverter{} class NodeType1Converter:INodeConverter{} class NodeType2Converter:INodeConver

我是DI容器领域的新手。我目前正在使用Windsor Castle,我正试图通过命名约定来配置我的容器。下面是我尝试做的一个例子:

interface INode{}
interface INodeType1: INode{}
interface INodeType2: INode{}

interface INodeConverter{}
class NodeType1Converter:INodeConverter{}
class NodeType2Converter:INodeConverter{}
它是一个应用程序,用户可以通过拖放不同类型的节点来构建流程图。在某一点上,这些节点必须以特定的格式进行转换,每个节点都有自己特定的转换方式

在解析INodeType1时,我希望接收NodeType1Converter的实例。当INodeType2-->节点类型转换程序

我尝试使用WithService注册它。选择但未成功:

container.Register(Classes.FromThisAssembly()
                .InSameNamespaceAs<INodeConverter>()
                .WithService.Select((type, types) => type.Name.EndsWith("Converter")  && type.Name .StartsWith ("don't know what to do here?!?")
                                                    ? new[] { type.BaseType }
                                                    : Enumerable.Empty<Type>()));
container.Register(Classes.fromthissembly())
.InSameNamespaceAs()
.WithService.Select((type,types)=>type.Name.EndsWith(“转换器”)和&type.Name.StartsWith(“不知道在这里做什么?!”)
?新[]{type.BaseType}
:Enumerable.Empty());
有人能帮我吗

谢谢,,
Philippe

请更新您的问题,以使用接口和类的真实名称。这使我们能够对设计进行反馈。