private string ComputeHashForResource(string resourceName)
 {
     using (var stream = this.assembly.GetManifestResourceStream(resourceName))
     {
         return(CompositePrecompiledMvcEngineWrapper.ComputeHash(stream));
     }
 }
        private string VirtualResourceHash(string virtualPath)
        {
            CompositePrecompiledMvcEngineWrapper.HashCacheRecord hashRecord;
            if (CompositePrecompiledMvcEngineWrapper.HashCache.ContainsKey(virtualPath))
            {
                hashRecord = CompositePrecompiledMvcEngineWrapper.HashCache[virtualPath];
                if (hashRecord.Dependency == null || !hashRecord.Dependency.HasChanged)
                {
                    return(hashRecord.Hash);
                }
            }

            lock (CompositePrecompiledMvcEngineWrapper.HashCache)
            {
                if (HostingEnvironment.VirtualPathProvider.FileExists(virtualPath))
                {
                    using (var stream = HostingEnvironment.VirtualPathProvider.GetFile(virtualPath).Open())
                    {
                        hashRecord = new CompositePrecompiledMvcEngineWrapper.HashCacheRecord()
                        {
                            Hash       = CompositePrecompiledMvcEngineWrapper.ComputeHash(stream),
                            Dependency = HostingEnvironment.VirtualPathProvider.GetCacheDependency(virtualPath, new object[0], DateTime.UtcNow)
                        };
                    }
                }
                else
                {
                    hashRecord = new CompositePrecompiledMvcEngineWrapper.HashCacheRecord()
                    {
                        Hash       = null,
                        Dependency = null
                    };
                }

                CompositePrecompiledMvcEngineWrapper.HashCache[virtualPath] = hashRecord;
            }

            return(hashRecord.Hash);
        }