/// <summary> /// Deserializes the hash table from a stream. /// NOTE: We want to deserialize to both the local and global HashTables /// FIXME: Need to put a check to ensure we don't add items twice? /// </summary> /// <param name="info">The info about the params</param> /// <param name="context">The serialized stream</param> protected ImageHashtable(SerializationInfo info, StreamingContext context) : this() { ImageHashTableCollection toDeserialize = (ImageHashTableCollection)info.GetValue("items", typeof(ImageHashTableCollection)); for (int i = 0; i < toDeserialize.items.Length; i++) { this.Add(toDeserialize.items[i].key, toDeserialize.items[i].image); } }
/// <summary> /// Serialize the hashtable of local images. /// </summary> /// <param name="info">The info about the params</param> /// <param name="context">The serialized stream</param> public void GetObjectData(SerializationInfo info, StreamingContext context) { ArrayList itemsToSerialize = new ArrayList(); foreach (ByteArray currentKey in this.ht.Keys) { itemsToSerialize.Add(new ImageHashtable.ImageHashTableItem(currentKey, (Image)this.ht[currentKey])); } ImageHashTableCollection toSerialize = new ImageHashTableCollection(); toSerialize.items = (ImageHashtable.ImageHashTableItem[])itemsToSerialize.ToArray(typeof(ImageHashtable.ImageHashTableItem)); info.AddValue("items", toSerialize); }
/// <summary> /// Serialize the hashtable of local images. /// </summary> /// <param name="info">The info about the params</param> /// <param name="context">The serialized stream</param> public void GetObjectData(SerializationInfo info, StreamingContext context) { ArrayList itemsToSerialize = new ArrayList(); foreach (ByteArray currentKey in this.ht.Keys) { itemsToSerialize.Add(new ImageHashtable.ImageHashTableItem(currentKey, (Image)this.ht[currentKey])); } ImageHashTableCollection toSerialize = new ImageHashTableCollection(); toSerialize.items = (ImageHashtable.ImageHashTableItem[])itemsToSerialize.ToArray(typeof(ImageHashtable.ImageHashTableItem)); info.AddValue("items", toSerialize); }