iserializable

Problem deserializing with NetDataContractSerializer after refactoring code

久未见 提交于 2019-12-04 09:16:49
I have a situation where I'm serializing some .NET objects using NetDataContractSerializer and storing the XML in a database as a way to remember the state of these objects within an application. Recently I just came across the first situation where some code refactoring of property and type names has resulted in the failure to deserialize this XML data. So far I've come up with two different plans of attack for how to deal with version compatibility breaks such as these which are to use facilities available within the NetDataContractSerializer itself to control the deserialization or just to

How to serialize an ISerializable object into SOAP or Json or Xml

China☆狼群 提交于 2019-12-04 05:55:37
问题 I have a complex object which is ISerializable and i want to serialize it into an XML document (node that i rather to not change the source code and add XML serialization attribute stuff). ISerializable works fine with BinaryFormatter, but there is no standard way to serialize it into XML or Json. The Json.NET library does support for serializing a ISerializable object into json, but there is a very small problem with that implementation, and that is the serializable constructor of class

How to serialize an ISerializable object into SOAP or Json or Xml

浪子不回头ぞ 提交于 2019-12-02 11:46:00
I have a complex object which is ISerializable and i want to serialize it into an XML document (node that i rather to not change the source code and add XML serialization attribute stuff). ISerializable works fine with BinaryFormatter, but there is no standard way to serialize it into XML or Json. The Json.NET library does support for serializing a ISerializable object into json, but there is a very small problem with that implementation, and that is the serializable constructor of class should be public in order to Json.net detect it (see this issue ) and this does make Json.net unusable for

ISerializable and backward compatibility

懵懂的女人 提交于 2019-11-30 20:38:34
I have to work an an old application that used binaryFormatter to serialize application data into filestream (say in a file named "data.oldformat") without any optimizazion the main class has been marked with attribute <serializable()>public MainClass ....... end class and the serialization code dim b as new binaryformatter b.serialize(mystream,mymainclass) In an attempt to optimize the serialization/deserialization process I simply made the class implement the ISerializable interface and wrote some optimized serialization routines <serializable()>public MainClass implements ISerializable ....

ISerializable and backward compatibility

廉价感情. 提交于 2019-11-30 05:06:17
问题 I have to work an an old application that used binaryFormatter to serialize application data into filestream (say in a file named "data.oldformat") without any optimizazion the main class has been marked with attribute <serializable()>public MainClass ....... end class and the serialization code dim b as new binaryformatter b.serialize(mystream,mymainclass) In an attempt to optimize the serialization/deserialization process I simply made the class implement the ISerializable interface and

What's the difference between using the Serializable attribute & implementing ISerializable?

一曲冷凌霜 提交于 2019-11-27 07:02:20
What's the difference between using the Serializable attribute and implementing the ISerializable interface? t0mm13b When you use the SerializableAttribute attribute you are putting an attribute on a field at compile-time in such a way that when at run-time, the serializing facilities will know what to serialize based on the attributes by performing reflection on the class/module/assembly type. [Serializable] public class MyFoo { … } The above indicates that the serializing facility should serialize the entire class MyFoo , whereas: public class MyFoo { private int bar; [Serializable] public

What is the point of the ISerializable interface?

北慕城南 提交于 2019-11-27 00:21:14
It seems like I can serialize classes that don't have that interface, so I am unclear on its purpose. ISerializable is used to provide custom binary serialization, usually for BinaryFormatter (and perhaps for remoting purposes). Without it, it uses the fields, which can be: inefficient; if there are fields that are only used for efficiency at runtime, but can be removed for serialization (for example, a dictionary may look different when serialized) inefficient; as even for fields that are needed it needs to include a lot of additional metadata invalid; if there are fields that cannot be

What is the point of the ISerializable interface?

女生的网名这么多〃 提交于 2019-11-26 09:21:00
问题 It seems like I can serialize classes that don\'t have that interface, so I am unclear on its purpose. 回答1: ISerializable is used to provide custom binary serialization, usually for BinaryFormatter (and perhaps for remoting purposes). Without it, it uses the fields, which can be: inefficient; if there are fields that are only used for efficiency at runtime, but can be removed for serialization (for example, a dictionary may look different when serialized) inefficient; as even for fields that