System.Runtime.Serialization.ISerializationSurrogate Interface

Assembly: Mscorlib.dll
Namespace: System.Runtime.Serialization
Summary
Implements a serialization surrogate selector that allows one object to perform serialization and deserialization of another.
C# Syntax:
public interface ISerializationSurrogate
See also:
System.Runtime.Serialization Namespace

System.Runtime.Serialization.ISerializationSurrogate Member List:

Public Methods
GetObjectData Populates the provided SerializationInfo with the data needed to serialize the object.
SetObjectData Populates the object using the information in the SerializationInfo.

System.Runtime.Serialization.ISerializationSurrogate Member Details

Method: GetObjectData(
   object obj,
   SerializationInfo info,
   StreamingContext context
)
Summary
Populates the provided SerializationInfo with the data needed to serialize the object.
C# Syntax:
void GetObjectData(
   object obj,
   SerializationInfo info,
   StreamingContext context
);
Parameters:

obj

The object to serialize.

info

The SerializationInfo to populate with data.

context

The destination (see StreamingContext) for this serialization.

Remarks
Extracts data from object obj and stores it in the SerializationInfoinfo.

Having located the surrogate, this method stores information on the object obj in the SerializationInfoinfo that describes its view of that object. This view includes the object's fields, properties, and current values. The SerializationInfo might correspond to the actual object, or it can be a synthesized view of the surrogate.

Return to top


Method: SetObjectData(
   object obj,
   SerializationInfo info,
   StreamingContext context,
   ISurrogateSelector selector
)
Summary
Populates the object using the information in the SerializationInfo.
C# Syntax:
object SetObjectData(
   object obj,
   SerializationInfo info,
   StreamingContext context,
   ISurrogateSelector selector
);
Parameters:

obj

The object to populate.

info

The information to populate the object.

context

The source from which the object is deserialized.

selector

The surrogate selector where the search for a compatible surrogate begins.

Return Value:
The populated deserialized object.
Remarks
The ISerializationSurrogate.SetObjectData method is called during deserialization. With this method, you can take the empty Objectobj that has already been created, and enter SerializationInfoinfo data into that object. Constructors are not invoked during deserialization of information and reconstruction of the object.

Return to top


Top of page

Copyright (c) 2002 Microsoft Corporation. All rights reserved.