You could include the object's Hash code when you export, then build a
unique list of hash codes when importing.  Build one object per hash
code, then hook the objects together based upon the relationships
specified by your input file.

-- R.B. Davidson

On Jun 17, 5:24 am, pth <[email protected]> wrote:
> Hello,
>
> I would like to export c# objects to text file (xml, json, csv, ...),
> allowing human to read it and edit it easily.
> Then, I would like to import c# objects in this file.
> It is easy to do it using XmlSerializer but it doesn't export object
> references so import failed, importing multiple times the same object.
> Example:
>         Pilot rb = new Pilot ("Rubens Barrichello");
>         Car car = new Car("BMW", rb);
>         car = new Car ("BrownGP", rb);
>
> If I export these 2 Car objects using XmlSerializer, no information is
> exported to specify that the pilot in these 2 cars is the same Pilot
> object.
> So the pilot is imported twice.
> How should I export these objects ?
> The example is using Xml but it could be another text format.
> Thanks in advance.
>
> Pierre.

Reply via email to