c# - Serializing an instance of an Interface that have a definition of a list of another interface -


this might sound repeated question other topics, defers in interface definition.

i have interface, lets named iclass1, contains in definition list of interfaces, iclass2

i have business unit implement interface; implementation naturally this

class class1: iclass1 {     ....whatever properties     list<iclass2> dataitems { get; set; } }  class class2:iclass2 {     ...whatever properties } 

the problem that, xmlserilizer complain list in class1, because interface! question is: simply, know type of instances should de-serialized in dataitems list, of type class2, how tell xml serializer that?

i've saw lot of workarounds, using dummy properties , ignore list of interfaces during serializing/de-serializing process suitable 1 think, , i don't want invent own serializer or re implement serialization in classes

if using datacontracts, can use knowntypeattribute give deserializer list of 1 or more types should use when deserializing.

the version takes string parameter lets specify name of method return sequence of types, can easier use in circumstances.

the link gave has sample code @ end of page.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -