X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.Core%2FSystem.Collections.Generic%2FHashSet.cs;h=39047dcd35804ffcc0443e90c7c3f49f7e7a9337;hb=f07dea5d0032d82118cb509a5d09b8992359eacc;hp=7f8bac21887ab19ac2897103788dae139e91aee9;hpb=f2f9d7933b87f398f45e42bda2426141d64a5416;p=mono.git diff --git a/mcs/class/System.Core/System.Collections.Generic/HashSet.cs b/mcs/class/System.Core/System.Collections.Generic/HashSet.cs index 7f8bac21887..39047dcd358 100644 --- a/mcs/class/System.Core/System.Collections.Generic/HashSet.cs +++ b/mcs/class/System.Core/System.Collections.Generic/HashSet.cs @@ -572,22 +572,51 @@ namespace System.Collections.Generic { return setComparer; } - [MonoTODO] [SecurityPermission (SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)] public virtual void GetObjectData (SerializationInfo info, StreamingContext context) { - throw new NotImplementedException (); + if (info == null) { + throw new ArgumentNullException("info"); + } + info.AddValue("Version", generation); + info.AddValue("Comparer", comparer, typeof(IEqualityComparer)); + info.AddValue("Capacity", (table == null) ? 0 : table.Length); + if (table != null) { + T[] tableArray = new T[table.Length]; + CopyTo(tableArray); + info.AddValue("Elements", tableArray, typeof(T[])); + } } - [MonoTODO] public virtual void OnDeserialization (object sender) { - if (si == null) - return; + if (si != null) + { + generation = (int) si.GetValue("Version", typeof(int)); + comparer = (IEqualityComparer) si.GetValue("Comparer", + typeof(IEqualityComparer)); + int capacity = (int) si.GetValue("Capacity", typeof(int)); + + empty_slot = NO_SLOT; + if (capacity > 0) { + table = new int[capacity]; + slots = new T[capacity]; + + T[] tableArray = (T[]) si.GetValue("Elements", typeof(T[])); + if (tableArray == null) + throw new SerializationException("Missing Elements"); + + for (int iElement = 0; iElement < tableArray.Length; iElement++) { + Add(tableArray[iElement]); + } + } else + table = null; - throw new NotImplementedException (); + si = null; + } } + IEnumerator IEnumerable.GetEnumerator () { return new Enumerator (this);