-
-
Save lindexi/abd158695f4e1fc8a543f793e9e7bf5a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/// <summary> | |
/// Uses the local list of accounts and returns an XML formatted string representing the list | |
/// </summary> | |
/// <returns>XML formatted list of accounts</returns> | |
public static string SerializeAccountListToXml() | |
{ | |
XmlSerializer xmlizer = new XmlSerializer(typeof(List<Account>)); | |
StringWriter writer = new StringWriter(); | |
xmlizer.Serialize(writer, AccountList); | |
return writer.ToString(); | |
} | |
/// <summary> | |
/// Takes an XML formatted string representing a list of accounts and returns a list object of accounts | |
/// </summary> | |
/// <param name="listAsXml">XML formatted list of accounts</param> | |
/// <returns>List object of accounts</returns> | |
public static List<Account> DeserializeXmlToAccountList(string listAsXml) | |
{ | |
XmlSerializer xmlizer = new XmlSerializer(typeof(List<Account>)); | |
TextReader textreader = new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(listAsXml))); | |
return AccountList = (xmlizer.Deserialize(textreader)) as List<Account>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment