msgpack和TParams互相转换
procedure msgpack2params(const Source: TMsgPack; Dest: TParams); var ps: TParams; p: TParam; i: Integer; begin ps := TParams.Create; try for i := 0 to Source.Count - 1 do begin p := TParam(ps.add); p.Value := Source.Items[i].AsVariant; end; Dest.Assign(ps); finally ps.Free; end; end; function params2msgpack(Params: TParams; Types: TParamTypes = AllParamTypes): TMsgPack; var I, Count: Integer; p: TParam; begin Result := TMsgPack.Create; Count := 0; for I := 0 to Params.Count - 1 do if Params[I].ParamType in Types then Inc(Count); if Count > 0 then begin for I := 0 to Params.Count - 1 do begin p := Params[I]; if p.ParamType in Types then Result.Force(p.Name).AsVariant := p.Value; end; end; end;