You are not logged in.
Pages: 1
Hi, (Delphi2009ent)
1. Is there a way to use variant properties in services?
We have a TCollectionItem with variant property and it doesn't stream over ...
2. Can we implement streamer for a particular datatype in general?
thank you,
Vojko Cendak
Offline
Hello,
1. Variants are not handled by now in the framework marshalling.
We may add it with not much difficulty, I guess.
What you can do is to marshall the TCollection as a custom type.
This is already working.
See http://blog.synopse.info/post/2012/04/1 … -any-class
2. It's a feature in progress: the ability to define properties by hand, including custom kind of properties.
See last commits in our source code repository:
http://synopse.info/fossil/timeline
So stay tuned, it will be finished soon!
It will first integrate it into TSQLRecord ORM level, but may be for any class in the future.
Online
thank you.
In RO and Kbm there is one dimensional streaming, meaning
pure single value variant or max one dimensional array in variant.
Offline
With mORMot, there is no variant support yet for services, but multi-dimensional array streaming of any other kind of array, and even records.
I suppose neither RO nor KBM handle those value-object types.
I'll add variant support for services in the roadmap.
Thanks for the feedback.
Online
They handle one-dimensional array of variants max.
Offline
I've introduced smvVariant kind of parameter for interface-based services.
See http://synopse.info/fossil/info/fd12ca0082
It is not fully tested yet, but you should be able to use variants in services parameters and results.
Not array of variants yet, nor directly variant properties in objects - but everything is in-place to handle it...
Online
Super, Can't wait to see it working in object properties.
Offline
Hi, delphi2009 ent
variant in object work only for one of getter/setter methods, if there are BOTH getter+setter method
we get access violation in
tkVariant: begin // stored as JSON, e.g. '1.234' or '"text"'
HR(P);
AddVariantJSON(PVariant(P^.GetFieldAddr(Value))^,twJSONEscape); // <== access v. with setter method or no setter method
end;
to reproduce ...
tmyobject=class(TPersistent)
private
fValue: variant;
fq: word;
function getValue: variant;
procedure setValue(const Value: variant);
published
published
property Value:variant read getValue write fValue; // if you put here BOTH getValue+setValue -> access violation; if there is onla one of getter/setter it works
property Quality:word read fq write fq;
end;
procedure TForm1.btnDemoClick(Sender: TObject);
var
lobj: tmyobject;
XML: RawUTF8;
begin
lobj := tmyobject.Create;
lobj.FValue := 1.34;
lobj.Quality := 192;
XML := ObjectToJSON(lobj);
Memo1.Text := XML;
end;
That would do us a lot of good,
because we have other proxy objects, which makes code complcated, less readable ...
Hope you will fix it ASAP.
thank you, vojko
Last edited by VojkoCendak (2013-05-30 21:55:43)
Offline
Hopefully you'll add variant arrays . That would be really nice.
thank you, vojko
Offline
I found a nice Variant streaming code on the website
http://npavlov.kodar.net/blog/?p=11
and
http://npavlov.kodar.net/blog/?p=12
Streaming full variant including arrays and varTypes
Although there are some errors and missing vartypes, it seems to work ok.
It streams with varType and also arrays.
I changed the code so that it's working.
Hope you'll find it interesting
Offline
Now variant published properties will use getter/setter, if available.
See http://synopse.info/fossil/info/551bd3f32e
It will fix the access violation problem.
Online
I've implemented variant in objects and it work's in production. It can translate even variant arrays
and it saves actual variant type.
Saved string is in hex. It's not JSON friendly but it could be used in some special cases.
Last edited by VojkoCendak (2013-08-06 19:55:37)
Offline
yes. Where can I do that ?
Offline
Pages: 1