Delphi 是否可以在Spring4D中多次注册同一类/接口?

Delphi 是否可以在Spring4D中多次注册同一类/接口?,delphi,spring4d,Delphi,Spring4d,我目前正在使用Spring4D框架,觉得它很酷。我正在努力实现以下目标 GlobalContainer.RegisterComponent<TPerson>.Implements<IPerson>('Normal'); GlobalContainer.RegisterComponent<TPerson>.Implements<IPerson>('TestData').DelegateTo( function: TPerson

我目前正在使用Spring4D框架,觉得它很酷。我正在努力实现以下目标

  GlobalContainer.RegisterComponent<TPerson>.Implements<IPerson>('Normal');
  GlobalContainer.RegisterComponent<TPerson>.Implements<IPerson>('TestData').DelegateTo(
    function: TPerson
    begin
      result := TPerson.Create;
      result.SetFirstName('Bob');
      result.SetSurname('Smith');
    end
  );
GlobalContainer.RegisterComponent.Implements('Normal');
GlobalContainer.RegisterComponent.Implements('TestData').DelegateTo(
职能:TPerson
开始
结果:=TPerson.Create;
result.SetFirstName('Bob');
result.SetSurname('Smith');
结束
);
TPerson/IPerson具有明显的定义。但不管我怎么做

  Person := ServiceLocator.GetService<IPerson>('Normal');
Person:=ServiceLocator.GetService('Normal');

Person:=ServiceLocator.GetService('TestData');

我总是明白鲍勃的意思,这是可能的还是我做错了什么?

这在最新版本的Spring4D中得到了修复。您使用的是最新的来源吗?RegisterComponent现在不推荐使用,您应该改用RegisterType,但使用这两种方法对我来说也不错。您的代码中可能发生了其他问题。请确保使用主干中的最新版本。此错误不应存在。@StefanGlienke希望签出最新版本,但我在防火墙后面,无法为svn计算正确的代理设置,我将在家中重试tonight@Jason我已经用另一个例子尽可能地把它去掉了,但仍然存在同样的问题。我使用的是Spring4D_V1.0.3.12.zip。
  Person := ServiceLocator.GetService<IPerson>('TestData');