using System; using System.Collections; using System.Runtime.InteropServices; namespace System.Runtime.Serialization { /// Generates IDs for objects. // Token: 0x02000481 RID: 1153 [ComVisible(true)] [MonoTODO("Serialization format not compatible with.NET")] [Serializable] public class ObjectIDGenerator { /// Initializes a new instance of the class. // Token: 0x06002C01 RID: 11265 RVA: 0x00090BB0 File Offset: 0x0008EDB0 public ObjectIDGenerator() { this.table = new Hashtable(ObjectIDGenerator.comparer, ObjectIDGenerator.comparer); this.current = 1L; } /// Returns the ID for the specified object, generating a new ID if the specified object has not already been identified by the . /// The object's ID is used for serialization. is set to true if this is the first time the object has been identified; otherwise, it is set to false. /// The object you want an ID for. /// true if was not previously known to the ; otherwise, false. /// The parameter is null. /// The has been asked to keep track of too many objects. // Token: 0x06002C03 RID: 11267 RVA: 0x00090BE4 File Offset: 0x0008EDE4 public virtual long GetId(object obj, out bool firstTime) { if (obj == null) { throw new ArgumentNullException("obj"); } object obj2 = this.table[obj]; if (obj2 != null) { firstTime = false; return (long)obj2; } firstTime = true; this.table.Add(obj, this.current); long num; this.current = (num = this.current) + 1L; return num; } /// Determines whether an object has already been assigned an ID. /// The object ID of if previously known to the ; otherwise, zero. /// The object you are asking for. /// true if was not previously known to the ; otherwise, false. /// The parameter is null. // Token: 0x06002C04 RID: 11268 RVA: 0x00090C4C File Offset: 0x0008EE4C public virtual long HasId(object obj, out bool firstTime) { if (obj == null) { throw new ArgumentNullException("obj"); } object obj2 = this.table[obj]; if (obj2 != null) { firstTime = false; return (long)obj2; } firstTime = true; return 0L; } // Token: 0x1700089A RID: 2202 // (get) Token: 0x06002C05 RID: 11269 RVA: 0x00090C8C File Offset: 0x0008EE8C internal long NextId { get { long num; this.current = (num = this.current) + 1L; return num; } } // Token: 0x04001100 RID: 4352 private Hashtable table; // Token: 0x04001101 RID: 4353 private long current; // Token: 0x04001102 RID: 4354 private static ObjectIDGenerator.InstanceComparer comparer = new ObjectIDGenerator.InstanceComparer(); // Token: 0x02000482 RID: 1154 private class InstanceComparer : IComparer, IHashCodeProvider { // Token: 0x06002C07 RID: 11271 RVA: 0x00090CB4 File Offset: 0x0008EEB4 int IComparer.Compare(object o1, object o2) { if (o1 is string) { return (!o1.Equals(o2)) ? 1 : 0; } return (o1 != o2) ? 1 : 0; } // Token: 0x06002C08 RID: 11272 RVA: 0x00090CE4 File Offset: 0x0008EEE4 int IHashCodeProvider.GetHashCode(object o) { return object.InternalGetHashCode(o); } } } }