Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Internet (https://www.clubdelphi.com/foros/forumdisplay.php?f=3)
-   -   ArrayOfAnyType (https://www.clubdelphi.com/foros/showthread.php?t=73497)

naverus 26-04-2011 20:48:24

ArrayOfAnyType
 
Hola:

Hice la conexión a un webservice (Visual C) , pero uno de los métodos requiere de arreglos de tipo ArrayOfAnytype, el problema es que esta clase no tiene un método add, alguien sabe como se puede manejar esta clase?
Código Delphi [-]
  
  ArrayOfAnyType = class(TRemotable)
  private
    FanyType: anyType;
  public
    FList: TList;
    constructor Create; override;
    function   GetVariantArray(Index: Integer): Variant;
    function   GetVariantArrayLength: Integer;
    property   VariantArray[Index: Integer]: Variant read GetVariantArray; default;
    property   Len: Integer read GetVariantArrayLength;
    procedure Add(Valor : TRemotable);
  published
    property anyType: anyType read FanyType write FanyType;
  end;

-------------------------------------------------------------------------
Código Delphi [-]
procedure ArrayOfAnyType.Add(Valor: TRemotable);
begin
  FList.Add(Valor);
end;

constructor ArrayOfAnyType.Create;
begin
  inherited Create;
  FSerializationOptions := [xoInlineArrays];
  FList := TList.Create();
end;

function ArrayOfAnyType.GetVariantArray(Index: Integer): Variant;
begin
  Result := FanyType[Index];
end;

function ArrayOfAnyType.GetVariantArrayLength: Integer;
begin
  if Assigned(FanyType) then
    Result := Length(FanyType)
  else
  Result := 0;
end;

naverus 27-04-2011 01:09:55

Faltaba
 
Genere el método add y quedo de la siguiente manera:
Código Delphi [-]
procedure ArrayOfAnyType.Add(item: variant);
var
  i : integer;
begin
  i := Len;
  SetLength(FanyType,i + 1);
  FanyType[i] := item;
end;
Pero, ahora como hago un casting de un variant a una clase de tipo TRemotable?

ecfisa 27-04-2011 01:58:36

Hola naverus.

Por favor encierra tu código entre las etiquetas [delphi] [/delphi] para que sea más legible. ( imágen explicativa ).

Un saludo y muchas gracias.

naverus 27-04-2011 20:26:22

Cast
 
mmm, no se que pase, agrege el metodo add al cual le paso como parametro la clase TRemote, lo agrega, pero el webservice no lo lee !!!


La franja horaria es GMT +2. Ahora son las 17:29:15.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi