From: Michael D. <mik...@us...> - 2004-08-07 04:57:23
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16270/NHibernate/Util Modified Files: SequencedHashMap.cs Log Message: removed Equals and GetHashCode made fully serializable fixed up ctors a little bit to be more like a Hashtable. Index: SequencedHashMap.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Util/SequencedHashMap.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SequencedHashMap.cs 12 Jul 2004 21:21:30 -0000 1.4 --- SequencedHashMap.cs 7 Aug 2004 04:57:13 -0000 1.5 *************** *** 1,2 **** --- 1,3 ---- + #region The Apache Software License, Version 1.1 /* This is a port from the Jakarta commons project */ *************** *** 57,63 **** --- 58,66 ---- * */ + #endregion using System; using System.Collections; + using System.Runtime.Serialization; namespace NHibernate.Util *************** *** 70,77 **** /// This class is not thread safe. /// </remarks> ! public class SequencedHashMap : IDictionary { ! private class Entry { private object _key; --- 73,82 ---- /// This class is not thread safe. /// </remarks> ! [Serializable] ! public class SequencedHashMap : IDictionary, ISerializable, IDeserializationCallback { ! [Serializable] ! private class Entry { private object _key; *************** *** 169,176 **** /// Construct a new sequenced hash map with default initial size and load factor /// </summary> ! public SequencedHashMap() { - _sentinel = CreateSentinel(); - _entries = new Hashtable(); } --- 174,179 ---- /// Construct a new sequenced hash map with default initial size and load factor /// </summary> ! public SequencedHashMap() : this(0, 1.0F, null, null) { } *************** *** 178,186 **** /// Construct a new sequenced hash map with the specified initial size and default load factor /// </summary> ! /// <param name="initialSize">the initial size for the hash table</param> ! public SequencedHashMap(int initialSize) { - _sentinel = CreateSentinel(); - _entries = new Hashtable(initialSize); } --- 181,187 ---- /// Construct a new sequenced hash map with the specified initial size and default load factor /// </summary> ! /// <param name="capacity">the initial size for the hash table</param> ! public SequencedHashMap(int capacity) : this(capacity, 1.0F, null, null) { } *************** *** 188,197 **** /// Construct a new sequenced hash map with the specified initial size and load factor /// </summary> ! /// <param name="initialSize">the initial size for the hashtable</param> /// <param name="loadFactor">the load factor for the hash table</param> ! public SequencedHashMap(int initialSize, float loadFactor) { - _sentinel = CreateSentinel(); - _entries = new Hashtable(initialSize, loadFactor); } --- 189,196 ---- /// Construct a new sequenced hash map with the specified initial size and load factor /// </summary> ! /// <param name="capacity">the initial size for the hashtable</param> /// <param name="loadFactor">the load factor for the hash table</param> ! public SequencedHashMap(int capacity, float loadFactor) : this(capacity, loadFactor, null, null) { } *************** *** 202,209 **** /// <param name="hcp"></param> /// <param name="comparer"></param> ! public SequencedHashMap(IHashCodeProvider hcp, IComparer comparer) { _sentinel = CreateSentinel(); ! _entries = new Hashtable(hcp, comparer); } --- 201,220 ---- /// <param name="hcp"></param> /// <param name="comparer"></param> ! public SequencedHashMap(IHashCodeProvider hcp, IComparer comparer) : this(0, 1.0F, hcp, comparer) ! { ! } ! ! /// <summary> ! /// Creates an empty Hashtable with the default initial capacity and using the default load factor, ! /// the specified hash code provider and the specified comparer ! /// </summary> ! /// <param name="capacity">the initial size for the hashtable</param> ! /// <param name="loadFactor">the load factor for the hash table</param> ! /// <param name="hcp"></param> ! /// <param name="comparer"></param> ! public SequencedHashMap(int capacity, float loadFactor, IHashCodeProvider hcp, IComparer comparer) { _sentinel = CreateSentinel(); ! _entries = new Hashtable(capacity, loadFactor, hcp, comparer); } *************** *** 434,452 **** #region System.Object Members - public override bool Equals(object obj) - { - if (obj == null) return false; - if (obj == this) return true; - - if (!(obj is IDictionary)) return false; - - return Keys.Equals(((IDictionary)obj).Keys); - } - - public override int GetHashCode() - { - return Keys.GetHashCode(); - } - public override string ToString() { --- 445,448 ---- *************** *** 524,527 **** --- 520,524 ---- } + private class ValuesCollection : ICollection { *************** *** 677,680 **** --- 674,708 ---- #endregion } + + + #region ISerializable Members + + SerializationInfo _info; + + protected SequencedHashMap(SerializationInfo info, StreamingContext context) + { + _info = info; + } + + public void GetObjectData(SerializationInfo info, StreamingContext context) + { + info.AddValue( "_sentinel", _sentinel, typeof(SequencedHashMap.Entry) ); + info.AddValue( "_modCount", _modCount ); + info.AddValue( "_entries", _entries ); + } + + #endregion + + #region IDeserializationCallback Members + + public void OnDeserialization(object sender) + { + _sentinel = (SequencedHashMap.Entry)_info.GetValue( "_sentinel", typeof(SequencedHashMap.Entry) ); + _modCount = _info.GetInt64("_modCount"); + _entries = (Hashtable)_info.GetValue( "_entries", typeof(Hashtable) ); + _info = null; + } + + #endregion } } |