Exemple #1
0
        public Task <CachedValue <T> > Get <T>(string key)
        {
            if (Dictionary.TryGetValue(new DictionaryKey(key, typeof(T).FullName), out var value))
            {
                return(Task.FromResult(CachedValue <T> .FromValue((T)value)));
            }

            return(Task.FromResult(CachedValue <T> .None));
        }
Exemple #2
0
        private CachedValue <T> Deserialize <T>(string strValue)
        {
            if (strValue == null)
            {
                return(CachedValue <T> .None);
            }

            if (typeof(T) == typeof(string))
            {
                return(CachedValue <T> .FromValue((T)(object)strValue));
            }

            return(CachedValue <T> .FromValue(JsonConvert.DeserializeObject <T>(strValue)));
        }