Piccolo.NET

PStream Class

PStream wraps a System.IO.Stream to handle optional elements.

For a list of all members of this type, see PStream Members.

System.Object
   PStream

public class PStream

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

This is similar to the concept of "weak references", but applied to object serialization rather than garbage collection. Here, PStream provides a method, WriteConditionalObject, which only serializes the specified object if there is a strong reference (if it has already been written) to that object elsewhere in the stream.

To discover strong references to objects, PStream uses a two-phase writing process. First, a "discovery" phase is used to find out what objects are about to be serialized. This works by effectively serializing the object graph to /dev/null, recording which objects are unconditionally written using the standard GetObjectData method. Then, in the second "write" phase, PStream actually serializes the data to the stream. During this phase, calls to WriteConditionalObject will only write the specified object if the object was found to be serialized during the discovery stage. If the object was not recorded during the discovery stage, a null value is unconditionally written in place of the object.

Requirements

Namespace: UMD.HCIL.Piccolo.Util

Assembly: UMD.HCIL.Piccolo (in UMD.HCIL.Piccolo.dll)

See Also

PStream Members | UMD.HCIL.Piccolo.Util Namespace