예제 #1
0
        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);
            }
        }
예제 #2
0
        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");
        }
예제 #3
0
 public void AddAFailedLoginAttemptFor(User user)
 {
     SetLockCountFor(user, GetLockCountFor(user) + 1);
 }