public static string SerializerDictionary(Dictionary<string, string> serializeObject) { var xmlDoc = new XmlDocument(); var xmlNode = xmlDoc.CreateNode(XmlNodeType.XmlDeclaration, "", ""); xmlDoc.AppendChild(xmlNode); var xmlElements = xmlDoc.CreateElement("", "Elements", ""); xmlDoc.AppendChild(xmlElements); foreach (var element in serializeObject) { var xmlElement = xmlDoc.CreateElement("", "Element", ""); xmlElements.AppendChild(xmlElement); var xmlAttribute = xmlDoc.CreateAttribute(element.Key); xmlAttribute.Value = element.Value; xmlElement.Attributes.Append(xmlAttribute); } return xmlDoc.InnerXml; } public static Dictionary<string, string> DerializeDictionary(string deserializeObject) { var deserializedDictionary = new Dictionary<string, string>(); var xmlDoc = new XmlDocument(); xmlDoc.LoadXml(deserializeObject); foreach (XmlElement element in xmlDoc.GetElementsByTagName("Element")) { deserializedDictionary.Add(element.Attributes[0].Name, element.Attributes[0].Value); } return null; }
Tuesday, July 19, 2011
SerializerDictionary / DerializeDictionary
Subscribe to:
Posts (Atom)