我目前正在玩 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');
我总是得到鲍勃,这是可能的还是我做错了什么?