C# 如何解析Castle Windsor中的代理类

C# 如何解析Castle Windsor中的代理类,c#,wcf,castle-windsor,wcffacility,C#,Wcf,Castle Windsor,Wcffacility,我有一个WCF服务,我正试图解决使用城堡温莎。以前的注册是这样的: container.Register(Component.For<IBatchDataService>() .AsWcfClient(WCFEndpoint .FromConfiguration("Internal.IBatchDataService")) .LifestyeTransient()) container.Register(Component.For()) .AsWcfClient(WCFEndpoi

我有一个WCF服务,我正试图解决使用城堡温莎。以前的注册是这样的:

container.Register(Component.For<IBatchDataService>()
.AsWcfClient(WCFEndpoint
.FromConfiguration("Internal.IBatchDataService"))
.LifestyeTransient())
container.Register(Component.For())
.AsWcfClient(WCFEndpoint
.FromConfiguration(“Internal.IBatchDataService”))
.lifestyTransient())
现在我已经创建了一个代理,它存在于进程中。它公开相同的接口(IBatchDataService),并将对WCF服务的引用作为构造函数参数。我如何在Windsor中设置它,以使任何其他类解析为使用代理类,但代理类解析为WCF服务。我现在有这个:

container.Register(Component.For<IBatchDataService>()
.ImplementedBy<BatchDataServiceClient>());
container.Register(Component.For())
.ImplementedBy());
这将解析新的代理类。

请尝试以下操作:

container.Register(
    Component.For<IBatchDataService>().AsWcfClient(WCFEndpoint.FromConfiguration("Internal.IBatchDataService")).LifestyeTransient().Named("wcfBatchDataService"),
    Component.For<IBatchDataService>().ImplementedBy<BatchDataServiceClient>().AsDefault().DependsOn(
        Dependency.OnComponent("constructorParameterName", "wcfBatchDataService")
)
container.Register(
Component.For().AsWcfClient(WCFEndpoint.FromConfiguration(“Internal.IBatchDataService”)).lifestyTransient().Named(“wcfBatchDataService”),
Component.For().ImplementedBy().AsDefault().DependsOn(
Dependency.OnComponent(“constructorParameterName”、“wcfBatchDataService”)
)
其中constructorParameterName是构造函数上IBatchDataService参数的名称。 我没有在编译器中运行它,所以请让我知道这是否适合您

亲切问候,, Marwijn.

试试这个:

container.Register(
    Component.For<IBatchDataService>().AsWcfClient(WCFEndpoint.FromConfiguration("Internal.IBatchDataService")).LifestyeTransient().Named("wcfBatchDataService"),
    Component.For<IBatchDataService>().ImplementedBy<BatchDataServiceClient>().AsDefault().DependsOn(
        Dependency.OnComponent("constructorParameterName", "wcfBatchDataService")
)
container.Register(
Component.For().AsWcfClient(WCFEndpoint.FromConfiguration(“Internal.IBatchDataService”)).lifestyTransient().Named(“wcfBatchDataService”),
Component.For().ImplementedBy().AsDefault().DependsOn(
Dependency.OnComponent(“constructorParameterName”、“wcfBatchDataService”)
)
其中constructorParameterName是构造函数上IBatchDataService参数的名称。 我没有在编译器中运行它,所以请让我知道这是否适合您

亲切问候,,
Marwijn.

这只是一种装饰图案。Windsor支持的It OOTB:

container.Register(
    Component.For<IBatchDataService>().
        ImplementedBy<BatchDataServiceClient>(),
    Component.For<IBatchDataService().
        AsWcfClient(WCFEndpoint.FromConfiguration("Internal.IBatchDataService")).
        LifestyleTransient());
container.Register(
组件。For()。
由()实现,

组件。对于而言,它只是一种装饰图案。Windsor支持的It OOTB:

container.Register(
    Component.For<IBatchDataService>().
        ImplementedBy<BatchDataServiceClient>(),
    Component.For<IBatchDataService().
        AsWcfClient(WCFEndpoint.FromConfiguration("Internal.IBatchDataService")).
        LifestyleTransient());
container.Register(
组件。For()。
由()实现,
组件。用于