在远程方案中使用IOC [英] Using IOC in a remoting scenario
问题描述
我正在努力让IOC在远程场景下工作。我已经设置了应用程序服务器来发布通过XML配置的服务(SingleCall)。
I'm struggling with getting IOC to work in a remoting scenario. I have my application server set up to publish Services (SingleCall) which are configured via XML.
此工作方式众所周知,
RemotingConfiguration.Configure(ConfigFile, true);
让我说我的服务看起来像这样(伪代码)
lets say my service looks like that (pseudocode)
public class TourService : ITourService
{
IRepository _repository;
public TourService()
{
_repository = new SqlServerRepository();
}
}
但我想确定的是此:
public class TourService : ITourService
{
IRepository _repository;
public TourService(IRepository repository)
{
_repository = repository;
}
}
在客户端,我们这样做(伪代码再次):
On the client side we do something like that (pseudocode again):
(ITourService)Activator.GetObject(ITourService, tcp://server/uri);
这提示服务器创建我的TourService类的新实例...
This prompts the server to create a new instance of my TourService class...
但是,这似乎不太奏效,因为.NET Remoting基础结构想知道应该发布的类型,但我想指出一下如何检索应发布的对象的方式。换句话说,将其路由到IOC流程管道(例如,以温莎城堡为例)。
However this doesn't seem to work out well because the .NET Remoting Infrastructure want's to know the type it should publish but I would rather like to point it to the way how it could retrieve the object it should publish. In other words, route it through the IOC process pipe of - let's say windsor castle - for example.
当前,我在该任务上有点迷路了...
Currently I'm a bit lost on that task...
推荐答案
如果您要使用温莎城堡,则可以使用远程处理设施来帮助您。看看文档。
If you are going to be using windsor castle there is a Remoting Facility that will help you out. Have a look at the documentation.
这篇关于在远程方案中使用IOC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!