XML serialization #2
-
Hi, Firstly, I realize I had posted a thread very recently regarding XML serialization, but I can't bump it and this is a different question :) I need to serialize a whole data structure, and as it happens I have more than one reference to the same object in different parts of my code, i.e. (trying to think of a simplified example) Imagine a shop that keeps track of each customer's favorite item:
class Shop { Customer customer; Item[] inventoryList; } class Customer { Item favoriteItem; }
When customer is initialised it will have a reference to an item in the inventorylist. As I understand it, the deserializer will generate a new instance of Item for the customer, or I can ignore it, in which case it will be null when I deserialize. Is there a simple solution to get it as a reference to the intended object? I realize that in this case I can just use an index in the array rather than a reference to store the favoriteItem, but this will require major refactoring of my code.