Esempio n. 1
0
        public Type GetType(byte[] item)
        {
            TKey key  = KeyExtractor.Extract(item);
            Type type = Types[key];

            return(type);
        }
Esempio n. 2
0
        public void DeleteAllByPersonId(String person_id)
        {
            KeyExtractor <Borrowing> keyExtractor = new KeyExtractor <Borrowing>();

            foreach (Borrowing borrowing in new List <Borrowing>(this.borrowingRepository.SelectAll().Where(x => x.person_id == person_id)))
            {
                this.borrowingRepository.Delete(keyExtractor.KeyValues(borrowing));
            }
        }
Esempio n. 3
0
        public static TValue GetEntry <TValue>(string cacheName, string key)
        {
            IValueExtractor extractor = new KeyExtractor(IdentityExtractor.Instance);
            IFilter         filter    = null;
            var             entry     = CacheFactory.GetCache(cacheName).GetValues(filter);

            return(entry != null
                ? JsonConvert.DeserializeObject <TValue>(entry.ToString())
                : default(TValue));
        }
Esempio n. 4
0
        public object GetObject(byte[] bytes)
        {
            TKey key = KeyExtractor.Extract(bytes);

            if (key != null && Types.TryGetValue(key, out var foundType) && foundType != null)
            {
                return(_elector.CreateObject(bytes, foundType));
            }

            return(null);
        }
        public void Clear()
        {
            if (MainRepository == null)
            {
                return;
            }

            KeyExtractor <T> keyExtractor = new KeyExtractor <T>();

            foreach (T item in new List <T>(MainRepository.SelectAll()))
            {
                MainRepository.Delete(keyExtractor.KeyValues(item));
            }
        }
        public async Task <Dictionary <TKey, TEntity> > GetMany(IEnumerable <TKey> keys, CancellationToken cancellationToken = default)
        {
            var tasks    = keys.Distinct().Select(key => TryGet(key, cancellationToken)).ToArray();
            var entities = await Task.WhenAll(tasks).ConfigureAwait(false);

            var result = new Dictionary <TKey, TEntity>();

            foreach (var entity in entities)
            {
                if (entity != null !)
                {
                    result.Add(KeyExtractor.Invoke(entity), entity);
                }
            }
            return(result);
        }
        public void TestNamedCacheIndex()
        {
            INamedCache     cache     = CacheFactory.GetCache(CacheName);
            IValueExtractor extractor = IdentityExtractor.Instance;

            cache.Clear();

            cache.AddIndex(extractor, false, null);

            cache.RemoveIndex(extractor);

            IComparer comparer = new SafeComparer();

            extractor = new KeyExtractor(IdentityExtractor.Instance);
            cache.AddIndex(extractor, true, comparer);

            cache.RemoveIndex(extractor);

            CacheFactory.ReleaseCache(cache);
            CacheFactory.Shutdown();
        }
Esempio n. 8
0
 public IEnumerable <Key> ExtractKeys(T target)
 {
     return(KeyExtractor.Invoke(target));
 }
 public IReadOnlyCollection <Key> ExtractKeys(T target)
 {
     return(KeyExtractor.Invoke(target));
 }