Click here to Skip to main content
15,895,746 members
Articles / Mobile Apps / Windows Mobile

CompactFormatterPlus: Generic Serializer for Full and Compact Framework

Rate me:
Please Sign up or sign in to vote.
4.78/5 (19 votes)
1 Mar 2008CPOL9 min read 113.6K   2.3K   42  
Generic serializer for full and Compact Framework
using System;

namespace CompactFormatter.Interfaces
{
	/// <summary>
	/// Every class who wants to use CustomSerialization must implement 
	/// this interface, it is a CompactFramework version of .NET ISerializable
	/// interface.
	/// On CompactFramework we don't have ISerializable interface, so 
	/// ICSerializable is declared by CompactFormatter, obviously it's interface
	/// is changed respect to ISerializable because we don't have SerializationInfo
	/// and StreamingContext on the CompactFramework and plus we've a reference to 
	/// CompactFormatter to make, if necessary, use of standard serialization algorithms 
	/// during custom serialization. 
	/// 
	/// </summary>
	public interface ICSerializable
	{

		// Implied a parameterless constructor (needed by CompactFormatter).
		// ISerializable();

		/// <summary>
		/// This function is invoked by CompactFormatter when serializing a 
		/// Custom Serializable object.
		/// </summary>
		/// <param name="parent">A reference to the CompactFormatter instance which called this method.</param>
		/// <param name="stream">The Stream where object data must be written</param>
		void SendObjectData(CompactFormatter parent, System.IO.Stream stream);

		/// <summary>
		/// This function is invoked by CompactFormatter when deserializing a
		/// Custom Serializable object.
		/// </summary>
		/// <param name="parent">A reference to the CompactFormatter instance which called this method.</param>
		/// <param name="stream">The Stream where object data must be read</param>
		void ReceiveObjectData(CompactFormatter parent, System.IO.Stream stream);		
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions