public Caching(HashSet <Assembly> assemblies, Func <string, string> getCacheFilePath = null, ICachingFaultInjector cachingFaultInjector = null)
            {
                getCacheFilePath = getCacheFilePath ?? (file => Path.Combine(AddinManager.CurrentAddin.PrivateDataPath, file));

                Assemblies                = assemblies;
                MefCacheFile              = getCacheFilePath("mef-cache");
                MefCacheControlFile       = getCacheFilePath("mef-cache-control");
                this.cachingFaultInjector = cachingFaultInjector;
            }
예제 #2
0
            public Caching(HashSet <Assembly> mefAssemblies, Func <string, string> getCacheFilePath = null, ICachingFaultInjector cachingFaultInjector = null)
            {
                getCacheFilePath = getCacheFilePath ?? (file => Path.Combine(AddinManager.CurrentAddin.PrivateDataPath, file));

                // TODO: .NET 4.7.2 has a capacity constructor - https://github.com/mono/monodevelop/issues/7198
                loadedAssemblies = new HashSet <Assembly> ();
                foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
                {
                    if (asm.IsDynamic)
                    {
                        continue;
                    }

                    loadedAssemblies.Add(asm);
                }

                MefAssemblies             = mefAssemblies;
                MefCacheFile              = getCacheFilePath("mef-cache");
                MefCacheControlFile       = getCacheFilePath("mef-cache-control");
                this.cachingFaultInjector = cachingFaultInjector;
            }
예제 #3
0
            static bool ValidateAssemblyCacheListIntegrity(HashSet <Assembly> assemblies, List <MefControlCacheAssemblyInfo> cachedAssemblyInfos, ICachingFaultInjector cachingFaultInjector)
            {
                var currentAssemblies = new Dictionary <string, Guid> (assemblies.Count);

                foreach (var asm in assemblies)
                {
                    currentAssemblies.Add(asm.Location, asm.ManifestModule.ModuleVersionId);
                }

                foreach (var assemblyInfo in cachedAssemblyInfos)
                {
                    cachingFaultInjector?.FaultAssemblyInfo(assemblyInfo);

                    if (!currentAssemblies.TryGetValue(assemblyInfo.Location, out var mvid))
                    {
                        return(false);
                    }

                    if (mvid != assemblyInfo.ModuleVersionId)
                    {
                        return(false);
                    }
                }
                return(true);
            }