Exemplo n.º 1
0
 internal override void CacheBuildResult(string cacheKey, BuildResult result, long hashCode, DateTime utcStart)
 {
     if (!BuildResultCompiledType.UsesDelayLoadType(result))
     {
         ICollection     virtualPathDependencies = result.VirtualPathDependencies;
         CacheDependency dependencies            = null;
         if (virtualPathDependencies != null)
         {
             dependencies = result.VirtualPath.GetCacheDependency(virtualPathDependencies, utcStart);
             if (dependencies != null)
             {
                 result.UsesCacheDependency = true;
             }
         }
         if (result.CacheToMemory)
         {
             CacheItemPriority normal;
             BuildResultCompiledAssemblyBase base2 = result as BuildResultCompiledAssemblyBase;
             if (((base2 != null) && (base2.ResultAssembly != null)) && !base2.UsesExistingAssembly)
             {
                 string   assemblyCacheKey = BuildResultCache.GetAssemblyCacheKey(base2.ResultAssembly);
                 Assembly assembly         = (Assembly)this._cache.Get(assemblyCacheKey);
                 if (assembly == null)
                 {
                     this._cache.UtcInsert(assemblyCacheKey, base2.ResultAssembly, null, Cache.NoAbsoluteExpiration, Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null);
                 }
                 CacheDependency dependency2 = new CacheDependency(0, null, new string[] { assemblyCacheKey });
                 if (dependencies != null)
                 {
                     AggregateCacheDependency dependency3 = new AggregateCacheDependency();
                     dependency3.Add(new CacheDependency[] { dependencies, dependency2 });
                     dependencies = dependency3;
                 }
                 else
                 {
                     dependencies = dependency2;
                 }
             }
             string memoryCacheKey = GetMemoryCacheKey(cacheKey);
             if (result.IsUnloadable)
             {
                 normal = CacheItemPriority.Normal;
             }
             else
             {
                 normal = CacheItemPriority.NotRemovable;
             }
             CacheItemRemovedCallback onRemoveCallback = null;
             if (result.ShutdownAppDomainOnChange || (result is BuildResultCompiledAssemblyBase))
             {
                 if (this._onRemoveCallback == null)
                 {
                     this._onRemoveCallback = new CacheItemRemovedCallback(this.OnCacheItemRemoved);
                 }
                 onRemoveCallback = this._onRemoveCallback;
             }
             this._cache.UtcInsert(memoryCacheKey, result, dependencies, result.MemoryCacheExpiration, result.MemoryCacheSlidingExpiration, normal, onRemoveCallback);
         }
     }
 }
Exemplo n.º 2
0
 internal virtual void RemoveAssemblyAndRelatedFiles(string assemblyName)
 {
     if (assemblyName.StartsWith("App_Web_", StringComparison.Ordinal))
     {
         string str     = assemblyName.Substring("App_Web_".Length);
         bool   gotLock = false;
         try
         {
             CompilationLock.GetLock(ref gotLock);
             DirectoryInfo info = new DirectoryInfo(this._cacheDir);
             foreach (FileInfo info2 in info.GetFiles("*" + str + ".*"))
             {
                 if (info2.Extension == ".dll")
                 {
                     string assemblyCacheKey = BuildResultCache.GetAssemblyCacheKey(info2.FullName);
                     HttpRuntime.CacheInternal.Remove(assemblyCacheKey);
                     RemoveAssembly(info2);
                     StandardDiskBuildResultCache.RemoveSatelliteAssemblies(assemblyName);
                 }
                 else if (info2.Extension == ".delete")
                 {
                     CheckAndRemoveDotDeleteFile(info2);
                 }
                 else
                 {
                     TryDeleteFile(info2);
                 }
             }
         }
         finally
         {
             if (gotLock)
             {
                 CompilationLock.ReleaseLock();
             }
             ShutDownAppDomainIfRequired();
         }
     }
 }