-
-
Save alanmcgovern/6b08bc8f2b15c730787b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Serializable] | |
public class MyDictionary<K, V> : Dictionary<K, V> | |
{ | |
public MyDictionary () | |
{ | |
} | |
protected MyDictionary(SerializationInfo info, | |
StreamingContext context) | |
{ | |
foreach (var v in (KeyValuePair<K, V>[]) info.GetValue ("contents", typeof (KeyValuePair<K, V>[]))) | |
Add (v.Key, v.Value); | |
} | |
public override void GetObjectData (SerializationInfo info, StreamingContext context) | |
{ | |
info.AddValue ("contents", this.ToArray ()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment