KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have the following code IProxy<T> = interface ['{1E3A98C5-78BA-4D65-A4BA-B6992B8B4783}'] function Setup : ISetup<T>; function Proxy : T; function CastAs<I : IInterface> : IInterface; end; Is there a way to work around the compiler error that is received when compiling? "[DCC Error] Delphi.Mocks.pas(123): E2535 Interface methods must not have parameterized methods" Basically I would like to have this interface be passed around and be able to cast off it, by passing in the type to cast to and having that type returned. I can achieve this with a class, however would prefer passing around an interface. Additional Info: Say I have the following class TInterfaceProxy<T> = class(TBaseProxy<T>) private type TProxyVirtualInterface = class(TVirtualInterface) private FProxy : TInterfaceProxy<T>; protected public function QueryInterface(const IID: TGUID; out Obj): HRESULT; override; stdcall; constructor Create(AProxy : TInterfaceProxy<T>; AInterface: Pointer; InvokeEvent: TVirtualInterfaceInvokeEvent); end; private FVirtualInterfaces : TDictionary<TGUID, TProxyVirtualInterface>; protected function InternalQueryInterface(const IID: TGUID; out Obj): HRESULT; stdcall; function QueryInterface(const IID: TGUID; out Obj): HRESULT; override; function Proxy : T;override; function CastAs<I: IInterface> : I; public constructor Create;override; destructor Destroy;override; end; CastAs works well here as the newly requested cast can be created a new virtual interface. Now if I want to pass this class around its fine. However if I require it as an interface i.e. TInterfaceProxy<T> = class(TBaseProxy<T>, IProxy<T>) it doesn't work understand that. Don't agree with it, but understand. Therefore how do I get around this restriction so that I can call a C
Tags (comma-separated)
Save Edits
Cancel