Deserialization only returns the last object of the same type.
alko89 opened this issue · 5 comments
After reading the ddd m file using the code from example:
DataFile vudf = VehicleUnitDataFile.Create();
vudf.Process("samples/ddd/M_20170303_1354_WDB96340610122689_20161203_20170303.DDD", writer_m);
The final DataFile object vudf
only contains the last element in the region if the file contains multiple nodes of the same element.
For example, my ddd file contains many elements of <TransferDataActivities>
, but only the last one is stored in the Regions array of vudf
object.
Also <TransferDataActivities>
then contains multiple rows of <ActivityChangeInfo>
elements and only the last one is stored in the vudf
object.
The same behaviour can be seen for C type files for <CardEventRecord>
Hi I'm not sure I understand the problem. You should not inspect the vudf object after processing, only the output xml. Let me know if this helps...
Hi
I figured it out this is probably because of reading config files and is not the intended behaviour.
I was thinking I would get the object file also containing the fields from xml like from these serialization examples:
https://docs.microsoft.com/en-us/dotnet/standard/serialization/examples-of-xml-serialization
It would be nice to have this though. It would make the library a lot more usefull.
The XmlSerializer is core to the library but only for reading the config files. It reads the config to construct the internal classes and then executes these against the ddd file.
I don't think DataSet is appropriate here because that's more for tabular data (perhaps with joins) whereas the ddd files contain a richer structure.
There was a suggestion previously that we create classes for all the structure in the tachograph specification and create this in memory as an intermediate result which can then optionally be written as XML. This would be quite a bit of work to do by hand. With a bit of clever code you could possibly auto-generate these classes from the config files -- the target schema is implicit in them.
Anyway, I'm going to close this one for now!
After reading the code some more, I found out its not working as I expected at first. Sorry for a false issue.
I have created classes for M type xml file. If you want to use those classes, I can send them to you.