反射(后期绑定)

uses System.Rtti;

type
  TMacBook = class
  public
    Name: string;
    procedure Restart;
  end;

procedure TMacBook.Restart;
begin
end;

var
  Ctx: TRttiContext;
  RType: TRttiType;
  Method: TRttiMethod;
  Field: TRttiField;
begin
  RType := Ctx.GetType(TMacBook);

  //show methods (own and inherited)
  for Method in RType.GetMethods do
    WriteLn(Method.Name);

  //show fields
  for Field in RType.GetFields do
    WriteLn(Field.Name);
end.