System.Runtime.Serialization.ObjectIDGenerator Class

Generates IDs for objects.

See Also: ObjectIDGenerator Members

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
public class ObjectIDGenerator

Remarks

The System.Runtime.Serialization.ObjectIDGenerator keeps track of previously identified objects. When you ask for the ID of an object, the System.Runtime.Serialization.ObjectIDGenerator knows whether to return the existing ID, or generate and remember a new ID.

The IDs are unique for the life of the System.Runtime.Serialization.ObjectIDGenerator instance. Generally, a System.Runtime.Serialization.ObjectIDGenerator life lasts as long as the System.Runtime.Serialization.Formatter that created it. Object IDs have meaning only within a given serialized stream, and are used for tracking which objects have references to others within the serialized object graph.

Using a hash table, the System.Runtime.Serialization.ObjectIDGenerator retains which ID is assigned to which object. The object references, which uniquely identify each object, are addresses in the runtime garbage-collected heap. Object reference values can change during serialization, but the table is updated automatically so the information is correct.

Object IDs are 64-bit numbers. Allocation starts from one, so zero is never a valid object ID. A formatter can choose a zero value to represent an object reference whose value is null.

Requirements

Namespace: System.Runtime.Serialization
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0