views:

337

answers:

2

When WSDL importer wizard generates the interfaces, all properties have the Index option, but reading the code and the InvokeRegistry unit, I can't found what is that for, anyone know if it is really necessary?

Like this

  Login = class(TRemotable)
  private
    [...] 
  published
    property User: string Index (IS_OPTN) read GetUser write SetUser stored User_Specified;
    [...]
  end;

I'm asking because I want to change this unit, adding some Interfaces to this classes, for integrate with MVP framework.

+2  A: 

IS_OPTN is passed to GetUser and SetUser via the 'Index' parameter when you access the user property.

The getters/setters probably look like this:

function GetUser(Index:Integer):String;
procedure SetUser(Index:Integer;const value:string);

So, think of it as this:

MyString := MyLogin.user;
// is translated to:
MyString := getUser(IS_OPTN);

and

MyLogin.user := 'me'; 
// is translated to:
SetUser(IS_OPTN,'me');
Wouter van Nifterick
Wouter, It is like that, but the parameter is not used inside any method, that why my question.
Cesar Romero
A: 

I found a more detailed explanation for this question, When using Indexes, several properties can share the same access methods.

A good example, from Delphi 2009 Help:

type 
   TRectangle = class 
     private 
       FCoordinates: array[0..3] of Longint; 
       function GetCoordinate(Index: Integer): Longint; 
       procedure SetCoordinate(Index: Integer; Value: Longint); 
     public 
       property Left: Longint index 0 read GetCoordinate write SetCoordinate; 
       property Top: Longint index 1 read GetCoordinate write SetCoordinate; 
       property Right: Longint index 2 read GetCoordinate write SetCoordinate; 
       property Bottom: Longint index 3 read GetCoordinate write SetCoordinate; 
       property Coordinates[Index: Integer]: Longint read GetCoordinate write SetCoordinate; 
       ... 
   end;

Note, all properties shares the same method access.

Cesar Romero