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 around the compiler error that was received during compilation?
"[DCC Error] Delphi.Mocks.pas (123): E2535 Interface methods must not have parameterized methods"
Basically, I would like this interface to be passed, and it will be able to discard it by passing the type to be sent and return that type. I can achieve this with a class, but would prefer going through the interface.
Additional Information:
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 recently requested cast can be created with a new virtual interface. Now, if I want to go through this class around his fine. However, if I require it as an interface, that is, TInterfaceProxy<T> = class(TBaseProxy<T>, IProxy<T>) , this will not work. Do not disagree with this, but understand.
Therefore, how can I get around this restriction so that I can call the CastAs function, pass in a type (any type of interface to start with) and be able to create a virtual interface from it?
Jason source share