Delphi 如何在Spring框架中使用的接口中实现参数化方法

Delphi 如何在Spring框架中使用的接口中实现参数化方法,delphi,interface,spring4d,Delphi,Interface,Spring4d,我正在尝试集成Aurelius ORM框架和Spring 4D框架,我在很大程度上取得了成功,但是Aurelius ORM(以及其他)依靠“对象管理器”在数据库中加载和保存对象。我正在做的部分工作是尽可能地分离类的实现和接口。然而,当为这个对象管理器(Aurelius中的TObjectManager)创建接口时,我很难实现对象管理器的“Find”方法。例如,对象管理器支持以下方法: MyObjectManager := TObjectManager.Create(Connection); Exi

我正在尝试集成Aurelius ORM框架和Spring 4D框架,我在很大程度上取得了成功,但是Aurelius ORM(以及其他)依靠“对象管理器”在数据库中加载和保存对象。我正在做的部分工作是尽可能地分离类的实现和接口。然而,当为这个对象管理器(Aurelius中的TObjectManager)创建接口时,我很难实现对象管理器的“Find”方法。例如,对象管理器支持以下方法:

MyObjectManager := TObjectManager.Create(Connection);
ExistingSale := MyObjectManager.Find<TSale>(1); // Find the Sale record with ID = 1 of the class TSale.
基本上,我需要想出一个接口函数,我可以在自己的对象管理器中调用它,例如:

function TMyOwnObjectManager.Find<T>(ID: Integer) : T;
begin
     Result:=fAureliusObjectManager.Find<T>(ID);
end;
函数TMyOwnObjectManager.Find(ID:Integer):T;
开始
结果:=fAureliusObjectManager.Find(ID);
结束;

感谢所有人的帮助,几天来我一直在尝试提出解决方案。

好的,虽然不是我在界面声明方面寻找的解决方案,但我设法克服了从TObjectManager继承并以以下方式重新声明Find函数的问题:

function TMyOwnManager.Find(Class: TClass; IdValue: Variant): TObject; 
begin 
    // Call the TObjectManager protected method "Find(Clazz:TClass; IdValue: Variant)" 
    Result := inherited Find(TClass(Class), IdValue); 
end;

希望它能对其他人有所帮助。

好的,虽然不是我在接口声明方面所寻找的解决方案,但我成功地克服了从TObjectManager继承并通过以下方式重新声明Find函数的问题:
函数TMyOwnManager.Find(Class:TClass;IdValue:Variant):TObject;开始//调用TObjectManager保护的方法“Find(Clazz:TClass;IdValue:Variant)”结果:=继承的Find(TClass(Class),IdValue);结束。如果有人知道接口声明的正确解决方案,我将保留这个问题。谢谢你的回答,如果它能解决你的问题。
function TMyOwnObjectManager.Find<T>(ID: Integer) : T;
begin
     Result:=fAureliusObjectManager.Find<T>(ID);
end;
function TMyOwnManager.Find(Class: TClass; IdValue: Variant): TObject; 
begin 
    // Call the TObjectManager protected method "Find(Clazz:TClass; IdValue: Variant)" 
    Result := inherited Find(TClass(Class), IdValue); 
end;