How to make TObjectDictionary.Values accessible as property?

Posted by Holgerwa on Stack Overflow See other posts from Stack Overflow or by Holgerwa
Published on 2010-12-22T11:25:17Z Indexed on 2010/12/22 11:54 UTC
Read the original article Hit count: 172

Filed under:
|
|

I have an object like this:

  TMyObj = class
  private
    FObjList: TObjectDictionary <integer, TMyObject>;
  public
    constructor Create;
    destructor Destroy;
    // How to access Values correctly? Something similar to this not working code
    property Values: TValueCollection read FObjList.Values write FObjList.Values;
  end;

  var MyObj: TMyObj;

To access the values of FObjList, I'd like to write:

  for tmpObject in MyObj.Values do
...

How do I need to declare the property "Values" so that MyObj.Values behaves exactly as if I would access MyObj.FObjList.Values?

© Stack Overflow or respective owner

Related posts about delphi

Related posts about generics