Ver Mensaje Individual
  #5  
Antiguo 19-06-2012
LoPiTaL LoPiTaL is offline
Miembro
 
Registrado: abr 2009
Posts: 168
Reputación: 16
LoPiTaL Va por buen camino
Hola,
Si estás usando Delphi 2010 o superior, tal vez te interese revisar la RTTI extendida, que permite hacer muchas más cosas que TypInfo y de forma más sencilla (más orientada a objetos). Simplemente incluye en el uses "RTTI", y añádete una variable de TRTTIContext, y verás cómo es más o menos sencillo:

Código Delphi [-]
//Ejemplo tomado de http://stackoverflow.com/questions/2...event-properly
function MethodAssigned(const aObject: TObject; const MethodName: string): Boolean;
var
  LContext: TRttiContext;
  LValue: TValue;
  LEvent: TNotifyEvent;
begin
  LValue:=LContext.GetType(aObject.ClassType).GetProperty(MethodName).GetValue(aObject);
  LEvent:=LValue.AsType();  //Los () son necesarios, para que el compilador distinga entre 
                                                           //llamar a AsType y lanzar el evento.
  if assigned(LEvent) then
    LEvent(Self);
end;

Un saludo,
LoPiTaL
Responder Con Cita