C # in a Nutshell, Second Edition

ISerializationSurrogate

System.Runtime.Serialization (mscorlib.dll) interface

Objects that implement this interface can be delegated to perform the serialization and deserialization of another object by providing customized methods for GetObjectData( ) and SetObjectData( ) . GetObjectData( ) gets the member information to create a SerializationInfo instance, while SetObjectData( ) uses information from a SerializationInfo instance to recreate an object.

public interface ISerializationSurrogate { // Public Instance Methods public void GetObjectData (object obj , SerializationInfo info , StreamingContext context ); public object SetObjectData (object obj , SerializationInfo info , StreamingContext context , ISurrogateSelector selector ); }

Returned By

ISurrogateSelector.GetSurrogate( ) , SurrogateSelector.GetSurrogate( )

Passed To

SurrogateSelector.AddSurrogate( )

Категории