Mirgation to 2.0 / Inheritance of TDictionary

70 views
Skip to first unread message

A P

unread,
Dec 30, 2023, 8:23:47 AM12/30/23
to Spring4D
Hi,
i prepare migration of my aplication to spring4d v.2xx.
Currently i've problems with some inherited classs from TDictionary.

Here ist a simple example:
uses
  Spring.Collections,
  Spring.Collections.Dictionaries;

type
  ITestMyDictItem = interface
    ['{785C061B-37A5-4C81-8D30-DD668CCF2613}']

  End;

type
  ITestInterface = interface(IDictionary<integer, ITestMyDictItem>)
    ['{19DE1B4A-7452-444E-8557-E218A97A3C59}']
    procedure Debug;
  End;
type
  TTestMyDictItem = class(TInterfacedObject, ITestMyDictItem)
   private
    FID: integer;
    function GetID: integer;
    procedure SetID(const Value: integer);
  public
    property ID: integer read GetID write SetID;
  end;

type

  TTestMyDict = class(TDictionary<integer, ITestMyDictItem>, ITestInterface)
  public
    procedure Debug;
  end;


in the following method i get the compiler error : KEYS is not declared (!)  ( with the version 1.22 works this fine.


procedure TTestMyDict.Debug;
var
  Lkey: integer;
begin
  for Lkey in Keys do
  begin

  end;

end;


Can somebody help me ?

Greetings Andy

Stefan Glienke

unread,
Jan 16, 2024, 6:01:04 AMJan 16
to Spring4D
The implementing class does not have the property definitions as they are not needed there - either add them in your class or access GetKeys instead of Keys.
Reply all
Reply to author
Forward
0 new messages