internal void SetLockCountFor(User user, int lockCount) { //there would obviously be some logic here to get the user but ommited for the sake of brevity using (FileStream fs = File.OpenWrite(PATH)) { Byte[] byteLockCount = new UTF8Encoding(true).GetBytes(lockCount.ToString()); fs.Write(byteLockCount, 0, byteLockCount.Length); } }
public int GetLockCountFor(User user) { //there would obviously be some logic here to get the user but ommited for the sake of brevity using (StreamReader re = File.OpenText(PATH)) { string input = null; while ((input = re.ReadLine()) != null) { return Convert.ToInt32(input); } } throw new Exception("Didn't work"); }
public void AddAFailedLoginAttemptFor(User user) { SetLockCountFor(user, GetLockCountFor(user) + 1); }