Forum: Object-Pascal / Delphi-Language
Delphi
by QuickAndDirty,
15. Mai 2019
// deklaration
Class Function GetClient<T:IInterface>(Addr: string):T;
Das hier lässt sich nicht kompilieren :(
Class Function TWSClient.GetClient<T>(Addr: string):T;
var RIO: THTTPRIO;
begin
Result := nil;
Forum: Object-Pascal / Delphi-Language
Delphi
by QuickAndDirty,
14. Mai 2019
Das hier compiliert
interface
...
Type
....
Class Function GetClient<T: IInterface>(Addr: string):T;
Forum: Object-Pascal / Delphi-Language
Delphi
by QuickAndDirty,
14. Mai 2019
in der Classe
interface
...
Type
....
Class Function GetClient<T: IInvokable>(Addr: string):T;
Forum: Object-Pascal / Delphi-Language
Delphi
by QuickAndDirty,
14. Mai 2019
Ja der gemeinsame Vorfahre von T ist IInvocable.
Forum: Object-Pascal / Delphi-Language
Delphi
by QuickAndDirty,
14. Mai 2019
T soll IInvocable sein...also ein Interface typ
Forum: Object-Pascal / Delphi-Language
Delphi
by QuickAndDirty,
14. Mai 2019
Ich versuche sowas
class Function TWSClient.GetClient<T>(Addr: string):T
var RIO: THTTPRIO;
begin
//Result := nil;// Das geht schonmal nicht aber ok
RIO := GetLocalRio;
try
Result := (RIO as T);// E2015 Operator ist auf diesen Operandentyp nicht anwendbar
RIO.URL := Addr;