[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Collections Hashtable.
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Collections Hashtable.cs, 1.10, 1.11 |
Date: |
Wed, 20 Aug 2003 01:00:10 -0400 |
Update of /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Collections
In directory subversions:/tmp/cvs-serv7951/runtime/System/Collections
Modified Files:
Hashtable.cs
Log Message:
Implement serialization for hash tables.
Index: Hashtable.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/Collections/Hashtable.cs,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** Hashtable.cs 26 May 2003 04:41:21 -0000 1.10
--- Hashtable.cs 20 Aug 2003 05:00:08 -0000 1.11
***************
*** 51,54 ****
--- 51,57 ----
private HashBucket[] table;
private int generation;
+ #if CONFIG_SERIALIZATION
+ private SerializationInfo info;
+ #endif
// Table of the first 400 prime numbers.
***************
*** 391,398 ****
#if CONFIG_SERIALIZATION
- [TODO]
protected Hashtable(SerializationInfo info, StreamingContext context)
{
! // TODO
}
--- 394,402 ----
#if CONFIG_SERIALIZATION
protected Hashtable(SerializationInfo info, StreamingContext context)
{
! // Save the serialization information for the
later call
! // to "OnDeserializationCallback".
! this.info = info;
}
***************
*** 848,863 ****
// Get the serialization data for this object.
- [TODO]
public virtual void GetObjectData(SerializationInfo info,
StreamingContext context)
{
! // TODO
}
// Process a deserialization callback.
- [TODO]
public virtual void OnDeserialization(Object sender)
{
! // TODO
}
--- 852,950 ----
// Get the serialization data for this object.
public virtual void GetObjectData(SerializationInfo info,
StreamingContext context)
{
! if(info == null)
! {
! throw new ArgumentNullException("info");
! }
! info.AddValue("LoadFactor", loadFactor);
! info.AddValue("Version", generation);
! info.AddValue("Comparer", comparer,
typeof(IComparer));
! info.AddValue("HashCodeProviderName", hcp,
!
typeof(IHashCodeProvider));
! info.AddValue("HashSize", (table == null ? 0 :
table.Length));
! Object[] temp = new Object [num];
! Keys.CopyTo(temp, 0);
! info.AddValue("Keys", temp, typeof(Object[]));
! Values.CopyTo(temp, 0);
! info.AddValue("Values", temp, typeof(Object[]));
}
// Process a deserialization callback.
public virtual void OnDeserialization(Object sender)
{
! // If the table is non-null, then we've been
re-entered.
! if(table != null)
! {
! return;
! }
!
! // Bail out if there is no de-serialization
information.
! if(info == null)
! {
! throw new ArgumentNullException("info");
! }
!
! // De-serialize the main parameter values.
! try
! {
! loadFactor =
info.GetSingle("LoadFactor");
! if(loadFactor < 0.1f)
! {
! loadFactor = 0.1f;
! }
! else if(loadFactor > 1.0f)
! {
! loadFactor = 1.0f;
! }
! }
! catch(NotImplementedException)
! {
! // Floating point not supported by the
runtime engine.
! }
! generation = info.GetInt32("Version");
! comparer = (IComparer)(info.GetValue
! ("Comparer",
typeof(IComparer)));
! hcp = (IHashCodeProvider)(info.GetValue
! ("HashCodeProvider",
typeof(IHashCodeProvider)));
! int hashSize = info.GetInt32("HashSize");
! if(hashSize > 0)
! {
! capacity = hashSize;
! try
! {
! capacityLimit = (int)(hashSize
* loadFactor);
! }
! catch(NotImplementedException)
! {
! // Floating point not supported
by the runtime engine.
! capacityLimit = capacity;
! }
! table = new HashBucket [hashSize];
! }
!
! // Get the key and value arrays from the
serialization data.
! Object[] keys = (Object[])(info.GetValue
! ("Keys", typeof(Object[])));
! Object[] values = (Object[])(info.GetValue
! ("Values", typeof(Object[])));
! if(keys == null || values == null)
! {
! throw new SerializationException
! (_("Serialize_StateMissing"));
! }
! if(keys.Length != values.Length)
! {
! throw new SerializationException
!
(_("Serialize_KeyValueMismatch"));
! }
!
! // Add the (key, value) pairs to the hash table.
! int posn;
! for(posn = 0; posn < keys.Length; ++posn)
! {
! Add(keys[posn], values[posn]);
! }
}
***************
*** 919,922 ****
--- 1006,1013 ----
return hcp__;
}
+ set
+ {
+ hcp__ = value;
+ }
}
***************
*** 953,962 ****
}
#if CONFIG_SERIALIZATION
- [TODO]
internal SynchronizedHashtable(SerializationInfo info,
StreamingContext context)
: base(info, context)
{
! // TODO
}
#endif
--- 1044,1058 ----
}
#if CONFIG_SERIALIZATION
internal SynchronizedHashtable(SerializationInfo info,
StreamingContext context)
: base(info, context)
{
! table = (Hashtable)
! (info.GetValue("ParentTable",
typeof(Hashtable)));
! if(table == null)
! {
! throw new SerializationException
!
(_("Serialize_StateMissing"));
! }
}
#endif
***************
*** 1149,1157 ****
// Get the serialization data for this object.
- [TODO]
public override void GetObjectData(SerializationInfo info,
StreamingContext context)
{
! // TODO
}
--- 1245,1256 ----
// Get the serialization data for this object.
public override void GetObjectData(SerializationInfo info,
StreamingContext context)
{
! if(info == null)
! {
! throw new
ArgumentNullException("info");
! }
! info.AddValue("ParentTable", table,
typeof(Hashtable));
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnetlib/runtime/System/Collections Hashtable.cs, 1.10, 1.11,
Rhys Weatherley <address@hidden> <=