C# DataContract Serialization, how to deserialize to already existing instance
I have a class, which holds a static dictionary of all existing instances, which are defined at compile time. Basically it looks like this: [DataContract] class Foo { private static Dictionary<long, Foo> instances = new Dictionary<long, Foo>(); [DataMember] private long id; public static readonly Foo A = Create(1); public static readonly Foo B = Create(2); public static readonly Foo C = Create(3); private static Foo Create(long id) { Foo instance = new Foo(); instance.id = id; instances.Add(instance); return instance; } public static Foo Get(long id) { return instances[id]; } } There are other