I'm in the process of writing a WCF application which will be consumed by a Silverlight application. I have done most of the design work and I am now doing the implementation, which has made me come up with this question.
Here's an example of something that exists in my application:
[DataContract]
class Person
{
[DataMember]
private Towel mostRecentlyUsedTowel;
[DataMember]
private Gym gym; //the gym that this person attends
...
}
[DataContract]
class Gym
{
[DataMember]
private List<Towel> towels; //all the towels this gym owns
...
}
Here's what I'm getting at: In my application mostRecentlyUsedTowel will be pointing at something in the towels list for the person's gym. Some of my requests will serialize a Person object.
Is the DataContractSerializer smart enough to notice its being asked to serialize the exact same instance of an object twice? If so, how does it deal with it?
If it will just go about serializing the same instance twice, how should I deal with this so I'm not sending unnecessary data over the link?