CHAPTER 20 FILE I/O AND OBJECT SERIALIZATION
public interface IRemotingFormatter : IFormatter
{
object Deserialize(Stream serializationStream, HeaderHandler handler);
void Serialize(Stream serializationStream, object graph, Header[] headers);
}
Although you might not need to interact directly with these interfaces for most of your serialization
endeavors, recall that interface-based polymorphism allows you to hold an instance of BinaryFormatter
or SoapFormatter using an IFormatter reference. Therefore, if you want to build a method that can
serialize an object graph using either of these classes, you could write the following:
static void SerializeObjectGraph(IFormatter itfFormat,
Stream destStream, object graph)
{
itfFormat.Serialize(destStream, graph);
}
Type Fidelity Among the Formatters
The m