public static void Serialize(IDictionary dictionary, String filePath) { DictionarySerializer dictionarySerializer = new DictionarySerializer(dictionary); XmlSerializer serializer = new XmlSerializer(typeof(DictionarySerializer)); using (System.IO.TextWriter textWriter = new System.IO.StreamWriter(filePath)) { serializer.Serialize(textWriter, dictionarySerializer); textWriter.Close(); } }
public static Dictionary <String, String> Deserialize(String filePath) { DictionarySerializer dictionarySerializer = null; using (TextReader textReader = new StreamReader(filePath)) { XmlSerializer deserializer = new XmlSerializer(typeof(DictionarySerializer)); dictionarySerializer = (DictionarySerializer)deserializer.Deserialize(textReader); textReader.Close(); } return(GetDictionaryFromHashMap((Hashtable)dictionarySerializer.dictionary)); }