Nja, was sagt denn der ClassName von TBananenKorb?
Delphi-Quellcode:
uses
TypInfo,
Generics.Collections;
type
TTest1 = TList<Integer>;
//TTest2 = type TList<Integer>; // [DCC Fehler] E2574 Instantiierter Typ kann nicht für TYPE-Typdeklaration verwendet werden
TTest2 = type TList;
//TTest3 = specialize TList<Integer>;
TTest4 = class(TList<Integer>);
procedure TForm1.FormCreate(Sender: TObject);
begin
ShowMessage('TypeName + ClassName + ParentClassName = Type<>SourceType' + sLineBreak
+ PTypeInfo(TypeInfo(TTest1)).Name + ' + ' + TTest1.ClassName + ' + ' + TTest1.ClassParent.ClassName + ' = ' + BoolToStr(TypeInfo(TTest1) = TypeInfo(TList<Integer>), True) + #10
+ PTypeInfo(TypeInfo(TTest2)).Name + ' + ' + TTest2.ClassName + ' + ' + TTest2.ClassParent.ClassName + ' = ' + BoolToStr(TypeInfo(TTest2) = TypeInfo(TList{<Integer>}), True) + #10
//+ PTypeInfo(TypeInfo(TTest3)).Name + ' + ' + TTest3.ClassName + ' + ' + TTest3.ClassParent.ClassName + ' = ' + BoolToStr(TypeInfo(TTest3) = TypeInfo(TList<Integer>), True) + #10
+ PTypeInfo(TypeInfo(TTest4)).Name + ' + ' + TTest4.ClassName + ' + ' + TTest4.ClassParent.ClassName + ' = ' + BoolToStr(TypeInfo(TTest4) = TypeInfo(TList<Integer>), True));
// TypeName + ClassName + ParentClassName = Type<>SourceType
// TList<System.Integer> + TList<System.Integer> + TEnumerable<System.Integer> = True
// TTest2 + TList + TObject = False
// TTest4 + TTest4 + TList<System.Integer> = False
end;
Code:
TypeName + ClassName + ParentClassName = Type<>SourceType
TList<System.Integer> + TList<System.Integer> + TEnumerable<System.Integer> = True
TTest2 + TList<System.Integer> + TEnumerable<System.Integer> = False (wenn es mit TList<> gegangen wäre)
TTest3 ?
TTest4 + TTest4 + TList<System.Integer> = False