public void WriteUser(string login, DateTime? expire) { CurrentUser = new User() { Login = login }; Settings = new Settings() { LastUserName = login, LoginDate = DateTime.Now, Expire = expire ?? DateTime.Now }; StorageLocalWrite(GetHashString(login), CurrentUser); StorageLocalWrite(Const.FileSettings, Settings); }
public bool LoadLastUser() { Settings = StorageLocalRead<Settings>(Const.FileSettings); if (Settings != null && !string.IsNullOrWhiteSpace(Settings.LastUserName)) { if (Settings.Expire > DateTime.Now) { CurrentUser = StorageLocalRead<User>(GetHashString(Settings.LastUserName)); return true; } else { CurrentUser = null; Settings = null; } } return false; }
public void ClearData() { if (!string.IsNullOrEmpty(Settings.LastUserName)) { StorageLocalDelete(GetHashString(Settings.LastUserName)); } CurrentUser = null; Settings = null; StorageLocalDelete(Const.FileSettings); }