Пример #1
0
        private static void MergeItems(FileSystemItem a, CacheItem b)
        {
            if (b == null) return;

            a.Title = b.Title;
            a.TitleType = (TitleType)b.TitleType;
            a.ContentType = (ContentType)b.ContentType;
            a.Thumbnail = b.Thumbnail;
            a.RecognitionState = (RecognitionState)b.RecognitionState;
        }
Пример #2
0
 public CacheItem Set(string key, FileSystemItem fileSystemItem, DateTime? expiration, DateTime? date, long? size, byte[] content)
 {
     var hashKey = key.Hash();
     var entry = new CacheItem
     {
         Id = hashKey,
         Expiration = expiration,
         Date = date,
         Size = size,
         Title = fileSystemItem.Title,
         Type = (int)fileSystemItem.Type,
         TitleType = (int)fileSystemItem.TitleType,
         ContentType = (int)fileSystemItem.ContentType,
         RecognitionState = (int)fileSystemItem.RecognitionState,
         Thumbnail = fileSystemItem.Thumbnail,
         Content = content
     };
     _inMemoryCache.Remove(hashKey);
     _inMemoryCache.Add(hashKey, entry);
     ResetTimer();
     return entry;
 }
Пример #3
0
 private void MigrateCacheItem(EsentPersistentDictionary cacheStore, IDbConnection db, string key)
 {
     var v = cacheStore.Get<CacheEntry<FileSystemItem>>(key);
     var c = new CacheItem
     {
         Id = key.SubstringAfter("_"),
         Date = v.Date,
         Expiration = v.Expiration,
         Size = v.Size,
         Title = v.Content.Title,
         Type = (int)v.Content.Type,
         TitleType = (int)v.Content.TitleType,
         ContentType = (int)v.Content.ContentType,
         Thumbnail = v.Content.Thumbnail,
         Content = string.IsNullOrEmpty(v.TempFilePath) ? null : File.ReadAllBytes(v.TempFilePath),
         RecognitionState = (int)v.Content.RecognitionState
     };
     db.Insert(c);
 }