Beispiel #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);
         }
     }
 }
Beispiel #2
0
        private void RemoveAssemblyAndCleanupDependenciesNoLock(string assemblyName)
        {
            string   assemblyCacheKeyFromName = BuildResultCache.GetAssemblyCacheKeyFromName(assemblyName);
            Assembly assembly = (Assembly)this._cache[assemblyCacheKeyFromName];

            if (assembly != null)
            {
                string assemblyCodeBase = Util.GetAssemblyCodeBase(assembly);
                this._cache.Remove(assemblyCacheKeyFromName);
                ICollection is2 = this._dependentAssemblies[assemblyName] as ICollection;
                if (is2 != null)
                {
                    foreach (string str3 in is2)
                    {
                        this.RemoveAssemblyAndCleanupDependenciesNoLock(str3);
                    }
                    this._dependentAssemblies.Remove(assemblyCacheKeyFromName);
                }
                RemoveAssembly(assemblyCodeBase);
            }
        }
Beispiel #3
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();
         }
     }
 }