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.3, 1.4
Date: Sun, 03 Aug 2003 05:03:37 -0400

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

Modified Files:
        ObjectIDGenerator.cs 
Log Message:


Begin implementing the outgoing side of the binary formatter.


Index: ObjectIDGenerator.cs
===================================================================
RCS file: 
/cvsroot/dotgnu-pnet/pnetlib/runtime/System/Runtime/Serialization/ObjectIDGenerator.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** ObjectIDGenerator.cs        4 Jun 2003 06:55:18 -0000       1.3
--- ObjectIDGenerator.cs        3 Aug 2003 09:03:35 -0000       1.4
***************
*** 31,34 ****
--- 31,35 ----
        // Internal state.
        private Hashtable table;
+       private Hashtable typeTable;
        private long nextId;
  
***************
*** 37,40 ****
--- 38,42 ----
                        {
                                table = new IdentityHashtable();
+                               typeTable = new IdentityHashtable();
                                nextId = 1;
                        }
***************
*** 57,60 ****
--- 59,63 ----
                                        firstTime = true;
                                        table[obj] = (Object)(nextId);
+                                       RegisterType(obj.GetType(), nextId);
                                        return nextId++;
                                }
***************
*** 78,81 ****
--- 81,109 ----
                                        firstTime = true;
                                        return 0;
+                               }
+                       }
+ 
+       // Register a type with a previous object identifier that used the type.
+       private void RegisterType(Type type, long id)
+                       {
+                               if(typeTable[type] == null)
+                               {
+                                       typeTable[type] = (Object)id;
+                               }
+                       }
+ 
+       // Get the object identity of an object of a specific type.
+       // This is used to cache type structure information between objects.
+       // Returns -1 if there was no previous object with the given type.
+       internal long GetIDForType(Type type)
+                       {
+                               Object obj = typeTable[type];
+                               if(obj != null)
+                               {
+                                       return (long)obj;
+                               }
+                               else
+                               {
+                                       return -1;
                                }
                        }





reply via email to

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