Enhanced C#
Loyc library documentation
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Public Member Functions | List of all members
Loyc.SyncLib.Impl.ObjectIdGenerator Class Reference

Assigns a unique long ID (starting at 1) to each distinct object reference presented to it. More...


Source file:

Remarks

Assigns a unique long ID (starting at 1) to each distinct object reference presented to it.

This is a drop-in replacement for System.Runtime.Serialization.ObjectIDGenerator, which Microsoft marked obsolete in .NET 8 (SYSLIB0050, "Formatter-based serialization is obsolete and should not be used"). The observable behaviour is the same: IDs are assigned sequentially starting at 1, objects are compared by reference identity, and GetId reports whether the object had been seen before.

Public Member Functions

long GetId (object obj, out bool firstTime)
 Gets the ID of obj , assigning a new one if this is the first time the object has been seen. More...
 
long HasId (object obj, out bool firstTime)
 Returns the ID previously assigned to obj , or 0 if the object has not been seen. Does not assign a new ID. More...
 

Member Function Documentation

long Loyc.SyncLib.Impl.ObjectIdGenerator.GetId ( object  obj,
out bool  firstTime 
)
inline

Gets the ID of obj , assigning a new one if this is the first time the object has been seen.

Parameters
firstTimeSet to true if a new ID was assigned.
Exceptions
ArgumentNullExceptionobj was null.
long Loyc.SyncLib.Impl.ObjectIdGenerator.HasId ( object  obj,
out bool  firstTime 
)
inline

Returns the ID previously assigned to obj , or 0 if the object has not been seen. Does not assign a new ID.