internal void RollbackState() { if (previousState != null) { TotalItemCount = previousState.TotalItemCount; IsLoaded = previousState.IsLoaded; var fetchedKeys = FetchedKeys; InitializeFetchedKeys(); InitializeDifferenceCollections(); foreach (var fetchedKey in fetchedKeys) { FetchedKeys.Add(fetchedKey); } foreach (var addedKey in previousState.AddedKeys) { if (fetchedKeys.ContainsKey(addedKey)) { FetchedKeys.Remove(addedKey); } addedKeys.Add(addedKey, addedKey); } foreach (var removedKey in previousState.RemovedKeys) { if (!FetchedKeys.ContainsKey(removedKey)) { FetchedKeys.Add(removedKey); } removedKeys.Add(removedKey, removedKey); } } }
/// <summary> /// Determines whether cached state contains specified item. /// </summary> /// <param name="key">The key.</param> /// <returns>Check result.</returns> public bool Contains(Key key) { if (removedKeys.ContainsKey(key)) { return(false); } if (addedKeys.ContainsKey(key)) { return(true); } if (FetchedKeys.ContainsKey(key)) { return(true); } return(false); }