diff options
author | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2003-10-21 14:54:22 +0400 |
---|---|---|
committer | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2003-10-21 14:54:22 +0400 |
commit | 43f3a01c49ad8f0230cd0572d075851e3bd340eb (patch) | |
tree | 772de391879aa0727f3b3f06655622c3346cdb71 /mcs/class/System/System.Collections.Specialized | |
parent | 6d45bb31a5fc8d1778de54a2627ab80cc23125d9 (diff) |
2003-10-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* NameObjectCollectionBase.cs: added serialization support.
svn path=/trunk/mcs/; revision=19264
Diffstat (limited to 'mcs/class/System/System.Collections.Specialized')
-rwxr-xr-x | mcs/class/System/System.Collections.Specialized/ChangeLog | 4 | ||||
-rw-r--r-- | mcs/class/System/System.Collections.Specialized/NameObjectCollectionBase.cs | 80 |
2 files changed, 66 insertions, 18 deletions
diff --git a/mcs/class/System/System.Collections.Specialized/ChangeLog b/mcs/class/System/System.Collections.Specialized/ChangeLog index 0cf5154fd82..8db4fa8645a 100755 --- a/mcs/class/System/System.Collections.Specialized/ChangeLog +++ b/mcs/class/System/System.Collections.Specialized/ChangeLog @@ -1,3 +1,7 @@ +2003-10-21 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * NameObjectCollectionBase.cs: added serialization support. + 2003-09-04 Duncan Mak <duncan@ximian.com> Patches from Alon Gazit <along@mainsoft.com>. diff --git a/mcs/class/System/System.Collections.Specialized/NameObjectCollectionBase.cs b/mcs/class/System/System.Collections.Specialized/NameObjectCollectionBase.cs index b8a9be92e5d..dbb2b307eac 100644 --- a/mcs/class/System/System.Collections.Specialized/NameObjectCollectionBase.cs +++ b/mcs/class/System/System.Collections.Specialized/NameObjectCollectionBase.cs @@ -246,13 +246,30 @@ namespace System.Collections.Specialized return new _KeysEnumerator(this);
}
// GetHashCode
-
- // ISerializable
- public virtual void /*ISerializable*/ GetObjectData( SerializationInfo info, StreamingContext context )
- {
- throw new Exception("Not implemented yet");
- }
-
+ + // ISerializable + public virtual void GetObjectData (SerializationInfo info, StreamingContext context) + { + if (info == null) + throw new ArgumentNullException ("info"); + + int count = Count; + string [] keys = new string [count]; + object [] values = new object [count]; + int i = 0; + foreach (_Item item in m_ItemsArray) { + keys [i] = item.key; + values [i] = item.value; + i++; + } + + info.AddValue ("m_hashprovider", m_hashprovider); + info.AddValue ("m_comparer", m_comparer); + info.AddValue ("m_readonly", m_readonly); + info.AddValue ("keys", keys); + info.AddValue ("values", values); + } + // ICollection
public virtual int Count
{
@@ -274,14 +291,42 @@ namespace System.Collections.Specialized {
throw new NotImplementedException ();
}
-
-
- // IDeserializationCallback
- public virtual void OnDeserialization( object sender)
- {
- throw new Exception("Not implemented yet");
- }
-
+ + + // IDeserializationCallback + public virtual void OnDeserialization (object sender) + { + if (sender == null) + throw new ArgumentNullException ("sender"); + + SerializationInfo info = sender as SerializationInfo; + if (info == null) + throw new SerializationException ("The object is not a SerializationInfo"); + + m_hashprovider = (IHashCodeProvider) info.GetValue ("m_hashprovider", + typeof (IHashCodeProvider)); + + if (m_hashprovider == null) + throw new SerializationException ("The hash provider is null"); + + m_comparer = (IComparer) info.GetValue ("m_comparer", typeof (IComparer)); + if (m_comparer == null) + throw new SerializationException ("The comparer is null"); + + m_readonly = info.GetBoolean ("m_readonly"); + string [] keys = (string []) info.GetValue ("keys", typeof (string [])); + if (keys == null) + throw new SerializationException ("keys is null"); + + object [] values = (object []) info.GetValue ("values", typeof (object [])); + if (values == null) + throw new SerializationException ("values is null"); + + Init (); + int count = keys.Length; + for (int i = 0; i < count; i++) + BaseAdd (keys [i], values [i]); + } //--------------- Protected Instance Properties ----------------
/// <summary>
/// SDK: Gets or sets a value indicating whether the NameObjectCollectionBase instance is read-only.
@@ -319,9 +364,8 @@ namespace System.Collections.Specialized m_ItemsContainer.Add(name,newitem);
}
m_ItemsArray.Add(newitem);
-
-// throw new Exception("Not implemented yet");
- }
+ } + protected void BaseClear()
{
if (this.IsReadOnly)
|