Thursday, June 25, 2009

Chapter 5-Lesson 2

  • Use XML serialization when you need to exchange an object with an application that
    might not be based on the .NET Framework
  • Private members of a class are not serialized in XML. This means only public data is serialized.
  • System.Xml.Serialization namespace is required.
  • Xml serialization does not need [Serializable] attribute on a class. However the class must be public and should have a parameter-less constructor.
  • XmlIgnore Attribute is similar to NonSerialized Attribute.
  • Xml Schema Definition tool (Xsd.exe) is used to generate set of classes that are strongly typed according to a schema.
  • DataSet.WriteXml( )/ReadXml( ) methods may be used to serialize datasets into XML.
  • For other types of collections, use TextWriter, initialize it as a StreamWriter and supply this object to XmlSerializer instead of filename in first argument. Collection could be in second argument of Serialize( ) method.

No comments:

Post a Comment