msgpack和TParams互相转换
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;
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/14778302.html

浙公网安备 33010602011771号