From e6181c24124d97f2fbc932b8a68311e625463156 Mon Sep 17 00:00:00 2001 From: uzvkl Date: Tue, 11 Jun 2019 23:05:52 +0200 Subject: Move dsa related stuff to subfolder --- FireBase/Offline/OfflineCacheAdapter.cs | 152 -------------------------------- 1 file changed, 152 deletions(-) delete mode 100644 FireBase/Offline/OfflineCacheAdapter.cs (limited to 'FireBase/Offline/OfflineCacheAdapter.cs') diff --git a/FireBase/Offline/OfflineCacheAdapter.cs b/FireBase/Offline/OfflineCacheAdapter.cs deleted file mode 100644 index 3153d1b..0000000 --- a/FireBase/Offline/OfflineCacheAdapter.cs +++ /dev/null @@ -1,152 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; - -namespace Firebase.Database.Offline -{ - internal class OfflineCacheAdapter : IDictionary, IDictionary - { - private readonly IDictionary database; - - public OfflineCacheAdapter(IDictionary database) - { - this.database = database; - } - - public void CopyTo(Array array, int index) - { - throw new NotImplementedException(); - } - - public bool IsSynchronized { get; } - - public object SyncRoot { get; } - - object IDictionary.this[object key] - { - get => database[key.ToString()].Deserialize(); - - set - { - var keyString = key.ToString(); - if (database.ContainsKey(keyString)) - database[keyString] = new OfflineEntry(keyString, value, database[keyString].Priority, - database[keyString].SyncOptions); - else - database[keyString] = new OfflineEntry(keyString, value, 1, SyncOptions.None); - } - } - - ICollection IDictionary.Values { get; } - - ICollection IDictionary.Keys { get; } - - public bool Contains(object key) - { - return ContainsKey(key.ToString()); - } - - IDictionaryEnumerator IDictionary.GetEnumerator() - { - throw new NotImplementedException(); - } - - public void Remove(object key) - { - Remove(key.ToString()); - } - - public bool IsFixedSize => false; - - public void Add(object key, object value) - { - Add(key.ToString(), (T) value); - } - - public int Count => database.Count; - - public bool IsReadOnly => database.IsReadOnly; - - public ICollection Keys => database.Keys; - - public ICollection Values => database.Values.Select(o => o.Deserialize()).ToList(); - - public T this[string key] - { - get => database[key].Deserialize(); - - set - { - if (database.ContainsKey(key)) - database[key] = new OfflineEntry(key, value, database[key].Priority, database[key].SyncOptions); - else - database[key] = new OfflineEntry(key, value, 1, SyncOptions.None); - } - } - - public IEnumerator> GetEnumerator() - { - return database.Select(d => new KeyValuePair(d.Key, d.Value.Deserialize())).GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - public void Add(KeyValuePair item) - { - Add(item.Key, item.Value); - } - - public void Clear() - { - database.Clear(); - } - - public bool Contains(KeyValuePair item) - { - return ContainsKey(item.Key); - } - - public void CopyTo(KeyValuePair[] array, int arrayIndex) - { - throw new NotImplementedException(); - } - - public bool Remove(KeyValuePair item) - { - return database.Remove(item.Key); - } - - public void Add(string key, T value) - { - database.Add(key, new OfflineEntry(key, value, 1, SyncOptions.None)); - } - - public bool ContainsKey(string key) - { - return database.ContainsKey(key); - } - - public bool Remove(string key) - { - return database.Remove(key); - } - - public bool TryGetValue(string key, out T value) - { - OfflineEntry val; - - if (database.TryGetValue(key, out val)) - { - value = val.Deserialize(); - return true; - } - - value = default(T); - return false; - } - } -} \ No newline at end of file -- cgit v1.2.3-54-g00ecf