dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Runtime/Serialization


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Runtime/Serialization ObjectIDGenerator.cs,1.2,1.3
Date: Wed, 04 Jun 2003 02:55:20 -0400

Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Runtime/Serialization
In directory subversions:/tmp/cvs-serv13330/runtime/System/Runtime/Serialization

Modified Files:
        ObjectIDGenerator.cs 
Log Message:


Use a modified hash table for the object ID generator that
compares keys using object identity, not "Equals".


Index: ObjectIDGenerator.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Runtime/Serialization/ObjectIDGenerator.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** ObjectIDGenerator.cs        26 May 2003 04:41:21 -0000      1.2
--- ObjectIDGenerator.cs        4 Jun 2003 06:55:18 -0000       1.3
***************
*** 3,7 ****
   *                    "System.Runtime.Serialization.ObjectIDGenerator" class.
   *
!  * Copyright (C) 2002  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
--- 3,7 ----
   *                    "System.Runtime.Serialization.ObjectIDGenerator" class.
   *
!  * Copyright (C) 2002, 2003  Southern Storm Software, Pty Ltd.
   *
   * This program is free software; you can redistribute it and/or modify
***************
*** 36,40 ****
        public ObjectIDGenerator()
                        {
!                               table = new Hashtable();
                                nextId = 1;
                        }
--- 36,40 ----
        public ObjectIDGenerator()
                        {
!                               table = new IdentityHashtable();
                                nextId = 1;
                        }
***************
*** 80,83 ****
--- 80,108 ----
                                }
                        }
+ 
+       // Modified hash table class that uses object identity for the key.
+       // This way, it is possible for two objects that compare as "Equal"
+       // to be present in the hash table under separate identifiers.
+       private sealed class IdentityHashtable : Hashtable
+       {
+               // Constructor.
+               public IdentityHashtable() : base() {}
+ 
+               // Determine if an item is equal to a key value.
+               protected override bool KeyEquals(Object item, Object key)
+                               {
+                                       if(item is String)
+                                       {
+                                               // Strings with the same value 
compare as equal.
+                                               return item.Equals(key);
+                                       }
+                                       else
+                                       {
+                                               // Everything else needs object 
identity.
+                                               return (item == key);
+                                       }
+                               }
+ 
+       }; // class IdentityHashtable
  
  }; // class ObjectIDGenerator





reply via email to

[Prev in Thread] Current Thread [Next in Thread]