Exemplo n.º 1
0
        public static async Task <IEnumerable <TOutput> > RetreiveAllObjectFromStringStoreAsync <TOutput, TKey>(
            this IPersistentStore <TKey, string> store,
            CancellationToken token)
        {
            var inMemoryState = await store.GetAllValuesAsync(token).ConfigureAwait(false);

            return(inMemoryState.Select(one => InsightsUtil.DeSerialize <TOutput>(one.Value)).ToList());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Save an Object as string
        /// </summary>
        /// <typeparam name="TKey"></typeparam>
        /// <typeparam name="TValue"></typeparam>
        /// <param name="store"></param>
        /// <param name="key"></param>
        /// <param name="objectToBeStored"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static Task SerializeAndSaveObjectInStoreAsync <TKey, TValue>(
            this IPersistentStore <TKey, string> store,
            TKey key,
            TValue objectToBeStored,
            CancellationToken token)
        {
            Assert.IsNotNull(key, "key != null");
            Assert.IsFalse(objectToBeStored == null, "objectToBeStored != null");

            return(store.SetEntityAsync(key, InsightsUtil.Serialize(objectToBeStored), token));
        }
Exemplo n.º 3
0
        public static async Task <TOutput> CreateOrRetriveRetreiveObjectFromStoreAsync <TOutput, TKey>(
            this IPersistentStore <TKey, string> store,
            TKey key,
            TOutput defaultVal,
            CancellationToken token)
        {
            await store.SetIfNotPresentAsync(key, InsightsUtil.Serialize(defaultVal), token).ConfigureAwait(false);

            var deserialized = await store.GetEntityAsync(key, token).ConfigureAwait(false);

            return(InsightsUtil.DeSerialize <TOutput>(deserialized));
        }