![]() |
Interfaces vergleichen...
Hallo Zusammen!
Gibt es eine Möglichkeit eine Interface-Referencen zu vergleichen? So wie in
Delphi-Quellcode:
...
TObject is TEdit
Beispiel:
Delphi-Quellcode:
Vielleicht stehe ich auch auf dem Schlauch.. (Generics fällt aus D2007)
unit Unit1;
interface type IFoo1 = Interface ['{171A69B8-DF63-4E32-9431-8915EEAA2833}'] Function Bar(Const AValue : String); end; IFoo2 = Interface ['{4F32C2C0-972F-45F0-9A7E-8FC18A2105D7}'] Function Bar(Const AValue : String); end; Procedure DoBar(Const AFace : IInterface;Const AValue : String); implementation Procedure DoBar(Const AFace : IInterface;Const AValue : String); begin if AFace = IFoo1 then (AFace as IFoo1).Bar(AValue) else (AFace as IFoo2).Bar(AValue); end; end. Mavarik |
AW: Interfaces vergleichen...
Meinst Du "Supports"?
(Ich glaube es nicht wirklich, aber die Fragestellung klingt ja eindeutig...)
Delphi-Quellcode:
Function DoBar(Const AFace : IInterface;Const AValue : String);
var lFoo1: IFoo1; lFoo2: IFoo2; begin if Supports(AFace, IFoo1, lFoo1) then lFoo1.Bar(AValue); if Supports(AFace, IFoo2, lFoo2) then lFoo2.Bar(AValue); end; |
AW: Interfaces vergleichen...
Geht das nicht mit Supports?
|
AW: Interfaces vergleichen...
Ich liebe Pseudo Code, der voll von Syntax errors ist :roll:
Wie schon gesagt, SysUtils.Supports. Aber wäre durchaus mal ein Feature Request wert, den is Operator dahingehend zu erweitern, dass er das macht, was Supports macht. |
AW: Interfaces vergleichen...
Zitat:
|
AW: Interfaces vergleichen...
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:22 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz