Example #1
0
        private CustomVirtualFile SetEntry(string virtualPath, string hash, byte[] bytes)
        {
            var path     = NormalizeFilePath(virtualPath);
            var cacheKey = GetCacheKeyForFile(path);

            var vf = new CustomVirtualFile(virtualPath, hash, bytes);

            Cache.Set(GetCacheKeyForHash(path), vf.Hash, 2, false);
            Cache.Set(cacheKey, vf);
            return(vf);
        }
Example #2
0
        public void ContentVirutalFile_GetStream_Returns_ContentData()
        {
            var data        = Encoding.UTF8.GetBytes("ABCDEF");
            var virtualFile = new CustomVirtualFile("a.txt", new Asset(data, DateTime.Now));

            Assert.That(virtualFile.Name, Is.EqualTo("a.txt"));
            Assert.That(virtualFile.VirtualPath, Is.EqualTo("a.txt"));
            Assert.That(virtualFile.IsDirectory, Is.False);

            var stream = virtualFile.Open();

            Assert.That(stream, Is.Not.Null);
            Assert.That(stream, Is.EqualTo(new MemoryStream(data)));
        }
Example #3
0
        public override CustomVirtualFile GetFile(string virtualPath)
        {
            var info = EnsureFileHasEntry(virtualPath);

            if (info != null)
            {
                return(info);
            }

            var path = NormalizeFilePath(virtualPath);

            var cacheKey = GetCacheKeyForFile(path);

            CustomVirtualFile item = Cache.Get(cacheKey) as CustomVirtualFile;

            if (item != null)
            {
                Trace.TraceInformation("From cache: {0} - '{1}'", item, cacheKey);
                return(item);
            }

            return(null);
        }