public override void DeleteAll(string uniqueName) { lock (_cache) { if (_cache.ContainsKey(uniqueName)) { _cache.Remove(uniqueName); } } // find the directory. // var dir = FileItem.DirectoryHash(uniqueName); if (IsoStore.DirectoryExists(dir)) { PriorityQueue.AddStorageWorkItem(() => { lock (LockObject) { var files = IsoStore.GetFileNames(dir + "\\*"); foreach (var f in files) { var path = Path.Combine(dir, f); DeleteFileHelper(IsoStore, path); } } }); } }
private void AddFolder(string prefix, List <string> list) { foreach (string file in IsoStore.GetFileNames(prefix + "\\*")) { list.Add(prefix + "\\" + file); } foreach (string dir in IsoStore.GetDirectoryNames(prefix + "\\*")) { AddFolder(prefix + "\\" + dir, list); } }
private IEnumerable <string> GetFilesRecursive(string root) { string search = Path.Combine(root, "*"); List <string> files = new List <string>(); try { files.AddRange(IsoStore.GetFileNames(search)); } // These catch statements help with some rare exception stacks // similar to this: // // System.IO.IsolatedStorage.IsolatedStorageException // at System.IO.IsolatedStorage.IsolatedStorageFile.EnsureAccessToPath(String PathAllowed, String PathRequested) // at System.IO.IsolatedStorage.IsolatedStorageFile.GetFileDirectoryNames(String path, String msg, Boolean file) // at System.IO.IsolatedStorage.IsolatedStorageFile.GetFileNames(String searchPattern) // at AgFx.IsoStore.HashedIsoStoreProvider.GetItems(String uniqueName) // at AgFx.IsoStore.HashedIsoStoreProvider.GetLastestExpiringItem(String uniqueName) // at AgFx.CacheEntry.CacheValueLoader.FindCacheItem() // at AgFx.CacheEntry.CacheValueLoader.get_IsValid() // at AgFx.CacheEntry.LoadInternal(Boolean force) // at AgFx.CacheEntry.<>c__DisplayClass2.<Load>b__0() // at AgFx.PriorityQueue.WorkerThread.<>c__DisplayClass5.<WorkerThreadProc>b__3(Object s) // at System.Threading.ThreadPool.WorkItem.doWork(Object o) // at System.Threading.Timer.ring() // catch (InvalidOperationException) { } catch (IsolatedStorageException) { } foreach (var d in IsoStore.GetDirectoryNames(search)) { files.AddRange(GetFilesRecursive(Path.Combine(root, d))); } return(files); }
public override IEnumerable <CacheItemInfo> GetItems(string uniqueName) { CacheItemInfo item; if (_cache.TryGetValue(uniqueName, out item)) { return(new CacheItemInfo[] { item }); } // find the directory. // var dir = FileItem.DirectoryHash(uniqueName); if (IsoStore.DirectoryExists(dir)) { lock (LockObject) { string[] files = null; try { files = IsoStore.GetFileNames(dir + "\\*"); } catch (IsolatedStorageException) { // intermittent IsoStore exceptions on shutdown. files = new string[0]; } List <CacheItemInfo> items = new List <CacheItemInfo>(); foreach (var f in files) { CacheItemInfo cii = FileItem.FromFileName(f); if (cii != null) { items.Add(cii); } } var orderedItems = from i in items where i.UniqueName == uniqueName orderby i.ExpirationTime descending select i; foreach (var i in orderedItems) { if (item == null) { item = i; continue; } Delete(i); } if (item != null) { _cache[uniqueName] = item; return(new CacheItemInfo[] { item }); } } } return(new CacheItemInfo[0]); }