1

在超级对象中,ISuperObject 有一个名为“AsMethod”的方法,它的作用是什么?我如何使用它?

假设我有这段代码,我如何编组到 json 签名本身(带参数),以便我可以轻松地为 SOInvoke 准备好它?感谢大家。

例如,假设我有procedure hey('sup', 45, false);,我可以将它编组为{method: "hey", Arg0: "sup", Arg1: 45, Arg2: false}吗?

procedure TForm1.Test(const MyType: TMyType; const s: string);
begin
  case MyType of
    mtTry:
      showmessage('Try');
    mtHey:
      showmessage('Hey');
  else
    showmessage('Else');
  end;

  showmessage(s);
end;

procedure TForm1.Button1Click(Sender: TObject);
type
  TTestProc = procedure (const MyType: TMyType; const s: string) of object;
var
  Ctx: TSuperRttiContext;
  Sig: TTestProc;
begin
   Ctx := TSuperRttiContext.Create;

   Ctx.AsJson<TTestProc>(Sig(mtHey, 'hey'));


  // SOInvoke(Self, 'test', SO('{MyType: 1, Param: "shit"}'));

   Ctx.Free;
end;
4

0 回答 0