Created
December 28, 2012 16:44
Revisions
-
awrowse created this gist
Dec 28, 2012 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Serialization; using System.IO; namespace SSOTester { [Serializable()] public class SSOUser { public SSOUser() { GUID = Guid.NewGuid().ToString(); } public string SSAN { get; set; } public string FileType { get; set; } public string Component { get; set; } public string GUID { get; set; } public void Save() { String filepath = String.Format(@"{0}\SSO Test Data\{1}.xml", Environment.GetEnvironmentVariable("USERPROFILE"), this.GUID); (new FileInfo(filepath)).Directory.Create(); FileStream fs = new FileStream(filepath, FileMode.OpenOrCreate); TextWriter tw = new StreamWriter(fs); XmlSerializer ser = new XmlSerializer(typeof(SSOUser)); ser.Serialize(tw, this); tw.Close(); fs.Close(); } public static SSOUser Load(string guid) { SSOUser user = null; XmlSerializer ser = new XmlSerializer(typeof(SSOUser)); String filepath = String.Format(@"{0}\{1}.xml", Environment.GetEnvironmentVariable("USERPROFILE"), guid); if (File.Exists(filepath)) { FileStream fs = new FileStream(filepath, FileMode.Open); user = (SSOUser)ser.Deserialize(fs); fs.Close(); } return user; } } }