public TwitterKeys Get() { TwitterKeys keys = null; if (!File.Exists(file)) { keys = new TwitterKeys { }; Save(keys); return keys; } keys = null; StreamReader sr = null; try { sr = new StreamReader(file); var str = sr.ReadToEnd(); var serializer = new JavaScriptSerializer(); keys = serializer.Deserialize<TwitterKeys>(str); } finally { sr.Close(); sr.Dispose(); sr = null; } return keys; }
public void Save(TwitterKeys site) { StreamWriter sw = null; try { sw = new StreamWriter(file); var serializer = new JavaScriptSerializer(); var str = serializer.Serialize(site); sw.Write(str); sw.Flush(); } finally { sw.Close(); sw.Dispose(); sw = null; } }
public void SaveTwitterKeys(TwitterKeys keys) { _dal.TwitterKeysProvider.Save(keys); }