Пример #1
0
        public static async Task <IEnumerable <string> > ConcatAllKeys(this IKeyValueStore self, IEnumerable <string> result)
        {
            if (self != null)
            {
                var storeKeys = await self.GetAllKeys();

                if (storeKeys != null)
                {
                    var filteredStoreKeys = (storeKeys).Filter(e => !result.Contains(e));
                    result = result.Concat(filteredStoreKeys);
                }
            }
            return(result);
        }
Пример #2
0
 public async Task OnHasInternet(bool hasInet)
 {
     if (hasInet)
     {
         var keys = (await store.GetAllKeys()).ToList();
         foreach (var key in keys)
         {
             try {
                 if (await SendEventToExternalSystem(await store.Get <AppFlowEvent>(key, null)))
                 {
                     await store.Remove(key);
                 }
             } catch (Exception e) { Log.e(e); }
         }
     }
 }
Пример #3
0
        /// <summary> Runs typical requests on the passed store </summary>
        private static async Task TestIKeyValueStoreImplementation(IKeyValueStore store)
        {
            string myKey1           = "myKey1";
            var    myValue1         = "myValue1";
            string myKey2           = "myKey2";
            var    myValue2         = "myValue2";
            var    myFallbackValue1 = "myFallbackValue1";

            // test Set and Get of values:
            Assert.False(await store.ContainsKey(myKey1));
            Assert.Equal(myFallbackValue1, await store.Get(myKey1, myFallbackValue1));
            await store.Set(myKey1, myValue1);

            Assert.Equal(myValue1, await store.Get <string>(myKey1, null));
            Assert.True(await store.ContainsKey(myKey1));

            // Test replacing values:
            var oldVal = await store.Set(myKey1, myValue2);

            Assert.Equal(myValue1, oldVal);
            Assert.Equal(myValue2, await store.Get <string>(myKey1, null));

            // Test add and remove of a second key:
            Assert.False(await store.ContainsKey(myKey2));
            await store.Set(myKey2, myValue2);

            Assert.True(await store.ContainsKey(myKey2));

            var keys = await store.GetAllKeys();

            Assert.Equal(2, keys.Count());

            Assert.True(await store.Remove(myKey2));
            Assert.False(await store.ContainsKey(myKey2));

            // Test RemoveAll:
            Assert.True(await store.ContainsKey(myKey1));
            await store.RemoveAll();

            Assert.False(await store.ContainsKey(myKey1));
        }
Пример #4
0
 public Task <List <string> > GetAllKeys() => store.GetAllKeys();
Пример #5
0
 public Task <IEnumerable <string> > LoadAllIds()
 {
     return(db.GetAllKeys());
 }
 public static async Task <IEnumerable <T> > GetAll <T>(this IKeyValueStore self)
 {
     return(await GetRange <T>(self, await self.GetAllKeys()));
 }
Пример #7
0
 public override async Task <IEnumerable <UpdateEntry> > DownloadAllUpdateEntries()
 {
     return(await(await store.GetAllKeys()).MapAsync(key => store.Get <UpdateEntry>(key, null)));
 }
 public static async Task <IEnumerable <T> > GetAll <T>(this IKeyValueStore self)
 {
     return(await(await self.GetAllKeys()).MapAsync(key => self.Get <T>(key, default(T))));
 }
 public async Task <IEnumerable <string> > GetAllKeys()
 {
     return(await WrapWithTry <IEnumerable <string> >(() => { return wrappedStore.GetAllKeys(); }, null));
 }