/// <summary> /// Main method that is used for login /// </summary> /// <param name="action">Delegate to check inputed creadentials</param> /// <returns></returns> public bool Login(Func <bool> action) { Thread.Sleep(1); if (action == null) { throw new ArgumentNullException("Authorize error: Login action is not set"); } if (IsBlocked) { return(false); } var isAutenticated = action.Invoke(); if (isAutenticated) { CreateUnlock(0); return(true); } IUnlock unlocker = Unlocker; if (unlocker != null) { if (unlocker.IsActive) { return(false); } } SaveAttempt(); ProcessLocking(); return(false); }
public IUnlock GetLastUnlocker() { IUnlock result = null; if (Db.UnlocksStorage.Any()) { result = Db.UnlocksStorage.OrderByDescending(u => u.TimeOccurred).First(); } return(result); }
public bool CheckForCompletedUnlocks(int packIndex, int levelIndex) { SaveDataAccessor saveDataAccessor = new SaveDataAccessor(); Dictionary <int, bool> unlockDictionary = saveDataAccessor.GetDataValue <Dictionary <int, bool> >(SaveKeys.UNLOCK_SAVE_KEY); notificationsToCreate = new Queue <Unlock>(); int counter = 0; for (int i = 0; i < unlockSettings.unlocks.Count; i++) { IUnlock unlockInterface = unlockSettings.unlocks[i] as IUnlock; if (unlockInterface.CheckForCompletion(packIndex, levelIndex)) { if (unlockDictionary == null) { unlockDictionary = new Dictionary <int, bool>(); unlockDictionary.Add(i, true); saveDataAccessor.SetData(SaveKeys.UNLOCK_SAVE_KEY, unlockDictionary); DataTracker.dataTracker.SaveData(); AddNotificationToQueue(unlockSettings.unlocks[i]); counter++; } else if (!unlockDictionary.ContainsKey(i)) { unlockDictionary[i] = true; saveDataAccessor.SetData(SaveKeys.UNLOCK_SAVE_KEY, unlockDictionary); DataTracker.dataTracker.SaveData(); AddNotificationToQueue(unlockSettings.unlocks[i]); counter++; } } } return(counter > 0); }