我目前正在使用 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
);
TPerson/IPerson 具有明显的定义。但不管我是否尝试
Person := ServiceLocator.GetService<IPerson>('Normal');
或
Person := ServiceLocator.GetService<IPerson>('TestData');
我总是得到 Bob,这可能吗,还是我做错了什么?
最佳答案
这个在最新版的Spring4D中已经修复
关于delphi - Spring4D中是否可以多次注册同一个类/接口(interface)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18325788/