2

Give an object similar to:

public class MyObject : IInterfaceA
{
    public IEnumerable<IInterfaceB> MyList{get; set}
    public MyComplexObjectX{get; set;}
    public MyComplexObjectY{get; set;}
}

which may have a fairly complex graph.

Does anybody know the best means of serializing this whereby namespace changes would not be an issue on deserialization? Would Json be the way to go perhaps?

Secondly there is also a good bit of use of lists of interfaces, generics etc. Im happy to use known types with DataContractSerializer but I think I will have the issue with namespace changes then.

Performance, size of serialized object etc are not an issue for me right now.

Thanks.

clonesegg
  • 235
  • 3
  • 17
  • Are you using a relational database? – Rui Jarimba Nov 07 '13 at 16:20
  • Let's say you have `ClassB : IInterfaceB`, `ClassB` has more properties, and `MyList` contains a `ClassB`. Does it need to deserialize as a `ClassB` with the extra properties? Does this situation even come up? – Tim S. Nov 07 '13 at 16:23
  • @Rui Jarimba I will saving it to SqlServer – clonesegg Nov 07 '13 at 16:28
  • @Tim S. Yes that exact scenario will come up. – clonesegg Nov 07 '13 at 16:29
  • Additionally, MyList can contain several different objects that implement IInterfaceB – clonesegg Nov 07 '13 at 16:36
  • 1
    Hm..the solutions at http://stackoverflow.com/questions/2254872/using-json-net-converters-to-deserialize-properties might help. Since you want to avoid namespace changes being an issue, I don't think the built-in `TypeNameHandling` will work. Maybe you could implement something like it with a custom converter, but where it only specifies the type name, not the namespace, and then the namespace is resolved different in different contexts? – Tim S. Nov 07 '13 at 16:37

0 Answers0