Ver Mensaje Individual
  #5  
Antiguo 30-07-2012
elarys elarys is offline
Miembro
 
Registrado: abr 2007
Posts: 94
Reputación: 18
elarys Va por buen camino
Código Delphi [-]
{
En el procedimiento anterior el resultado lo pasaba a un array dinamico porque pensaba
que me hacian falta mas lineas, en este el resultado se carga en un stringlist y me ahorro
como 5 lineas de codigo jejeje, ver List.Add
}

procedure GetPropertyList(Obj: TObject; Filter: TTypeKinds; List: TStringList; Counter: integer);
var
  Names, Value, Tipo: string;
  PInfo: PPropInfo;
  PropList: PPropList;
  Count, i, j: integer;
  Ob: TObject;
begin
  Count := GetPropList(Obj.ClassInfo, Filter, nil);
  GetMem(PropList, Count * SizeOf(PPropInfo));
  GetPropList(Obj.ClassInfo, Filter, PropList);

  for i := 0 to Count -1 do
  begin
    Value := GetPropValue(Obj, Proplist[i].Name);
    PInfo := GetPropInfo(Obj, Proplist[i].Name);
    Names := UpperCase(Proplist[i].Name);

    if PInfo <> nil then
    begin
      case PInfo^.PropType^.Kind of
        tkUnknown: Tipo := 'Unknown';
        tkInteger: Tipo := 'Integer';
        tkChar: Tipo := 'Char';
        tkEnumeration: Tipo := 'Enumeration';
        tkFloat: Tipo := 'Float';
        tkString: Tipo := 'String';
        tkSet: Tipo := 'Set';
        tkClass: Tipo := 'Class';
        tkMethod: Tipo := 'Method';
        tkWChar: Tipo := 'WChar';
        tkLString: Tipo := 'LString';
        tkWString: Tipo := 'WString';
        tkVariant: Tipo := 'Variant';
        tkArray: Tipo := 'Array';
        tkRecord: Tipo := 'Record';
        tkInterface: Tipo := 'Interface';
        tkInt64: Tipo := 'Int64';
        tkDynArray: Tipo := 'DynArray';
      end;
    end;

    if Tipo = 'Class' then
    begin
      List.Add('<' + Names + '>');
      Ob := GetObjectProp(Obj, Proplist[i].Name);
      GetPropertyList(Ob, tkProperties, List, Counter + 1);
      List.Add('< /' + Names + '>');
    end
    else
    begin
      List.Add('<' + Names + '>' + Value + '< /' + Names + '>');
    end;
  end;
end;
Responder Con Cita