Пример #1
0
        private Assembly CreateShadowCopy(string requestedAssemblyLocation, FileInfo fileInfo, out string shadowCopyLocation)
        {
            shadowCopyLocation = string.Empty;
            string str      = this.AssemblyCache.CreateDirectory();
            string fileName = Path.GetFileName(requestedAssemblyLocation);

            shadowCopyLocation = Path.Combine(str, fileName);
            File.Copy(requestedAssemblyLocation, shadowCopyLocation);
            string str1 = Path.ChangeExtension(fileName, ".pdb");
            string str2 = Path.Combine(Path.GetDirectoryName(requestedAssemblyLocation), str1);

            if (Microsoft.Expression.Framework.Documents.PathHelper.FileExists(str2))
            {
                File.Copy(str2, Path.Combine(str, str1));
            }
            string[] files = Directory.GetFiles(Path.GetDirectoryName(requestedAssemblyLocation), "*.lic");
            for (int i = 0; i < (int)files.Length; i++)
            {
                string str3 = files[i];
                if (Microsoft.Expression.Framework.Documents.PathHelper.FileExists(str3))
                {
                    File.Copy(str3, Path.Combine(str, Path.GetFileName(str3)));
                }
            }
            Assembly assembly = ProjectAssemblyHelper.LoadFile(shadowCopyLocation);

            if (assembly == null)
            {
                return(null);
            }
            this.TryCacheSatelliteAssembly(assembly, Microsoft.Expression.Framework.Documents.PathHelper.GetDirectoryNameOrRoot(requestedAssemblyLocation));
            if (!assembly.GlobalAssemblyCache)
            {
                this.loadedAssemblies[requestedAssemblyLocation] = new AssemblyService.AssemblyInfo(fileInfo, shadowCopyLocation, assembly);
                if (this.AssemblyCached != null)
                {
                    this.AssemblyCached(null, new AssemblyCachedEventArgs(requestedAssemblyLocation, assembly));
                }
            }
            if (this.serviceProvider.AssemblyLoggingService() != null)
            {
                this.serviceProvider.AssemblyLoggingService().Log(new ShadowCopyAssemblyEvent(requestedAssemblyLocation, assembly));
            }
            if (this.AssemblyCopied != null)
            {
                this.AssemblyCopied(null, new AssemblyCopiedEventArgs(requestedAssemblyLocation, assembly, str));
            }
            return(assembly);
        }
Пример #2
0
        public void TryCacheSatelliteAssembly(Assembly baseAssembly, string originalAssemblyDirectory)
        {
            List <Assembly> assemblies = new List <Assembly>();

            foreach (string satelliteAssemblyName in ProjectAssemblyHelper.GetSatelliteAssemblyNames(baseAssembly, originalAssemblyDirectory))
            {
                Assembly assembly = ProjectAssemblyHelper.LoadFile(satelliteAssemblyName);
                if (assembly == null)
                {
                    continue;
                }
                assemblies.Add(assembly);
                this.satelliteAssemblies[assembly.FullName] = assembly;
            }
            this.satelliteAssembliesForMain[baseAssembly.FullName] = assemblies;
        }