private Assembly LoadLibraryAssembly(AssemblyName assemblyName) { Assembly assembly; if (assemblyName == null) { return(null); } string str = ProjectAssemblyHelper.CachedGetAssemblyFullName(assemblyName); if (this.loadedAssemblies.TryGetValue(str, out assembly)) { return(assembly); } if (this.librarySignatures.Contains(str)) { foreach (string probingPath in this.probingPaths) { string str1 = string.Concat(PathHelper.ResolveCombinedPath(probingPath, assemblyName.Name), ".dll"); AssemblyName assemblyName1 = ProjectAssemblyHelper.CachedGetAssemblyNameFromPath(str1); if (assemblyName1 == null || !ProjectAssemblyHelper.CachedGetAssemblyFullName(assemblyName1).Equals(str, StringComparison.OrdinalIgnoreCase)) { continue; } assembly = ProjectAssemblyHelper.LoadFrom(str1); if (assembly == null) { continue; } this.loadedAssemblies.Add(str, assembly); break; } } return(assembly); }
public AssemblyInformation ResolveAssembly(string path) { AssemblyName assemblyName = ProjectAssemblyHelper.CachedGetAssemblyNameFromPath(path); Assembly assembly = this.ResolvePlatformAssembly(assemblyName); if (assembly != null) { return(new AssemblyInformation(assembly) { IsPlatformAssembly = true }); } Assembly assembly1 = this.ResolveLibraryAssembly(assemblyName); if (assembly1 != null) { return(new AssemblyInformation(assembly1)); } Assembly assembly2 = this.ResolveInstalledAssembly(path); if (assembly2 != null) { return(new AssemblyInformation(assembly2)); } return(this.ResolveShadowCopyAssembly(path)); }
private Assembly ResolveInstalledAssembly(AssemblyName assemblyName) { Assembly assembly; string str = ProjectAssemblyHelper.CachedGetAssemblyFullName(assemblyName); Dictionary <string, Assembly> .ValueCollection.Enumerator enumerator = this.installedAssemblies.Values.GetEnumerator(); try { while (enumerator.MoveNext()) { Assembly current = enumerator.Current; if (current.FullName != str) { continue; } assembly = current; return(assembly); } return(null); } finally { ((IDisposable)enumerator).Dispose(); } return(assembly); }
private static string TryCopyResourceAssembly(Assembly cachedAssembly, string originalAssemblyDirectory, string resourceCulture) { string str = Path.Combine(originalAssemblyDirectory, resourceCulture); string str1 = Path.Combine(Microsoft.Expression.Framework.Documents.PathHelper.GetDirectoryNameOrRoot(cachedAssembly.Location), resourceCulture); string str2 = string.Concat(ProjectAssemblyHelper.GetAssemblyName(cachedAssembly).Name, ".resources.dll"); string str3 = Path.Combine(str, str2); string str4 = Path.Combine(str1, str2); if (!File.Exists(str3)) { return(null); } if (Microsoft.Expression.Framework.Documents.PathHelper.ArePathsEquivalent(str3, str4)) { return(str4); } if (File.Exists(str4)) { return(null); } if (!Microsoft.Expression.Framework.Documents.PathHelper.DirectoryExists(str1)) { Directory.CreateDirectory(str1); } File.Copy(str3, str4); return(str4); }
public Assembly GetCachedSatelliteAssembly(AssemblyName assemblyName) { Assembly assembly; if (this.satelliteAssemblies.TryGetValue(ProjectAssemblyHelper.CachedGetAssemblyFullName(assemblyName), out assembly)) { return(assembly); } return(null); }
public Assembly ResolveReferenceAssembly(Assembly runtimeAssembly) { Assembly assembly = null; if (!this.referenceAssemblyTable.TryGetValue(runtimeAssembly, out assembly)) { assembly = this.ResolveReferenceAssembly(ProjectAssemblyHelper.GetAssemblyName(runtimeAssembly)); this.referenceAssemblyTable[runtimeAssembly] = assembly; } return(assembly); }
internal ProjectAssembly(IProjectItem projectItem, Assembly runtimeAssembly, string path, bool isImplicitlyResolvedAssembly) { this.Path = path; this.RuntimeAssembly = runtimeAssembly; AssemblyName assemblyName = ProjectAssemblyHelper.GetAssemblyName(this.RuntimeAssembly); this.Name = assemblyName.Name; this.FullName = ProjectAssemblyHelper.CachedGetAssemblyFullName(assemblyName); this.IsImplicitlyResolved = isImplicitlyResolvedAssembly; this.ProjectItem = projectItem; }
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); }
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; }
public static string GetAssemblySpec(AssemblyName assemblyName) { string str = (assemblyName.CultureInfo == null || string.IsNullOrEmpty(assemblyName.CultureInfo.Name) ? "neutral" : assemblyName.CultureInfo.Name); string name = assemblyName.Name; string str1 = string.Concat(name, ", Culture=", str); if (!name.Equals("mscorlib", StringComparison.OrdinalIgnoreCase)) { string str2 = ProjectAssemblyHelper.EncodeHexString(assemblyName.GetPublicKeyToken()); if (str2 != null) { str1 = string.Concat(str1, ", PublicKeyToken=", (str2.Length == 0 ? "null" : str2)); } } return(str1); }
private static IEnumerable <string> CopyResourceAssemblies(Assembly cachedAssembly, string originalAssemblyDirectory) { string str = null; try { object[] customAttributes = cachedAssembly.GetCustomAttributes(false); int num = 0; while (num < (int)customAttributes.Length) { NeutralResourcesLanguageAttribute neutralResourcesLanguageAttribute = (Attribute)customAttributes[num] as NeutralResourcesLanguageAttribute; if (neutralResourcesLanguageAttribute == null) { num++; } else { str = neutralResourcesLanguageAttribute.CultureName; break; } } } catch (Exception exception) { } for (CultureInfo i = CultureInfo.CurrentUICulture; !i.Equals(CultureInfo.InvariantCulture); i = i.Parent) { string str1 = i.ToString(); if (str != null && string.Equals(str1, str, StringComparison.OrdinalIgnoreCase)) { str = null; } string str2 = ProjectAssemblyHelper.TryCopyResourceAssembly(cachedAssembly, originalAssemblyDirectory, str1); if (str2 != null) { yield return(str2); } } if (str != null) { string str3 = ProjectAssemblyHelper.TryCopyResourceAssembly(cachedAssembly, originalAssemblyDirectory, str); if (str3 != null) { yield return(str3); } } }
internal static bool CanAssemblyBeFoundInReferenceFolders(AssemblyName assemblyName, string assemblyPath, FrameworkName targetFramework) { bool flag; if (targetFramework == null) { return(false); } IEnumerable <string> strs = ToolLocationHelper.GetPathToReferenceAssemblies(targetFramework).Concat <string>(ProjectAssemblyHelper.GetAssemblyFolderExLocations(targetFramework).Distinct <string>()); using (IEnumerator <string> enumerator = strs.GetEnumerator()) { while (enumerator.MoveNext()) { using (IEnumerator <string> enumerator1 = Directory.EnumerateFiles(enumerator.Current).GetEnumerator()) { while (enumerator1.MoveNext()) { string current = enumerator1.Current; if (!Microsoft.Expression.Framework.Documents.PathHelper.ArePathsEquivalent(current, assemblyPath)) { if (!string.Equals(ProjectAssemblyHelper.TrimFiletypeFromAssemblyNameOrPath(current), assemblyName.Name, StringComparison.OrdinalIgnoreCase)) { continue; } AssemblyName assemblyNameFromPath = ProjectAssemblyHelper.GetAssemblyNameFromPath(current); if (assemblyNameFromPath == null || !string.Equals(assemblyNameFromPath.FullName, assemblyName.FullName, StringComparison.OrdinalIgnoreCase)) { continue; } flag = true; return(flag); } else { flag = true; return(flag); } } } } return(false); } return(flag); }
public static AssemblyName CachedGetAssemblyNameFromPath(string path) { if (string.IsNullOrEmpty(path)) { return(null); } if (!ProjectAssemblyHelper.pathToAssemblyNameCache.ContainsKey(path)) { ProjectAssemblyHelper.pathToAssemblyNameCache[path] = ProjectAssemblyHelper.GetAssemblyNameFromPath(path); } AssemblyName item = (AssemblyName)ProjectAssemblyHelper.pathToAssemblyNameCache[path]; if (item != null) { ProjectAssemblyHelper.CachedGetAssemblyFullName(item); } return(item); }
public Assembly ResolveReferenceAssembly(AssemblyName assemblyName) { Assembly assembly; using (IEnumerator <Assembly> enumerator = this.defaultUniverse.Assemblies.GetEnumerator()) { while (enumerator.MoveNext()) { Assembly current = enumerator.Current; if (!AssemblyName.ReferenceMatchesDefinition(assemblyName, current.GetName())) { continue; } assembly = current; return(assembly); } return(this.ResolveReferenceAssembly(ProjectAssemblyHelper.GetAssemblySpec(assemblyName))); } return(assembly); }
public Assembly ResolveAssembly(AssemblyName assemblyName) { Assembly assembly; Assembly assembly1 = null; if (!this.hasEntered) { lock (this.syncLock) { try { string str = ProjectAssemblyHelper.CachedGetAssemblyFullName(assemblyName); this.hasEntered = true; if (!this.blendAssemblies.TryGetValue(str, out assembly1)) { foreach (KeyValuePair <string, string> delayLoadedAssembly in this.delayLoadedAssemblies) { if (!string.Equals(str, delayLoadedAssembly.Key, StringComparison.OrdinalIgnoreCase)) { continue; } assembly1 = (delayLoadedAssembly.Value == null ? ProjectAssemblyHelper.Load(str) : ProjectAssemblyHelper.LoadFrom(delayLoadedAssembly.Value)); if (assembly1 != null) { this.blendAssemblies.Add(str, assembly1); } assembly = assembly1; return(assembly); } } } finally { this.hasEntered = false; } return(assembly1); } return(assembly); } return(assembly1); }
private Assembly ResolveInstalledAssembly(string path) { if (path == null) { throw new ArgumentNullException("path"); } Assembly assembly = null; if (this.installedAssemblies.TryGetValue(path, out assembly)) { return(assembly); } if (this.IsInstalledAssembly(path)) { assembly = ProjectAssemblyHelper.LoadFrom(path); } if (assembly != null) { this.installedAssemblies.Add(path, assembly); } return(assembly); }
public BlendAssemblyResolver() { UIThreadDispatcher.Instance.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(this.InitializeBlendLoadedAssemblies)); Assembly assembly = typeof(BlendAssemblyResolver).Assembly; string codeBase = assembly.CodeBase; codeBase = codeBase.Substring(0, codeBase.LastIndexOf('/') + 1); string localPath = (new Uri(codeBase)).LocalPath; string str = ProjectAssemblyHelper.GetAssemblyName(assembly).Version.ToString(); Dictionary <string, string> strs = new Dictionary <string, string>(8) { { string.Concat("Microsoft.Expression.Platform.WPF, Version=", str, ", Culture=neutral, PublicKeyToken=31bf3856ad364e35"), PathHelper.ResolveCombinedPath(localPath, "Microsoft.Expression.Platform.WPF.dll") }, { string.Concat("Microsoft.Expression.Platform.Silverlight, Version=", str, ", Culture=neutral, PublicKeyToken=31bf3856ad364e35"), PathHelper.ResolveCombinedPath(localPath, "Microsoft.Expression.Platform.Silverlight.dll") }, { "ActiproSoftware.Shared.Net20, Version=1.0.102.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", null }, { "ActiproSoftware.SyntaxEditor.Addons.DotNet.Net20, Version=4.0.283.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", null }, { "ActiproSoftware.SyntaxEditor.Net20, Version=4.0.283.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", null }, { "ActiproSoftware.WinUICore.Net20, Version=1.0.102.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", null }, { "Microsoft.Windows.Design.Interaction, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", PathHelper.ResolveCombinedPath(localPath, "Microsoft.Windows.Design.Interaction.dll") }, { "Microsoft.Windows.Design.Extensibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", PathHelper.ResolveCombinedPath(localPath, "Microsoft.Windows.Design.Extensibility.dll") } }; this.delayLoadedAssemblies = strs; }
public static bool IsSilverlightAssembly(string path) { bool flag; AssemblyMetadataHelper.IMetaDataDispenserEx dispenser = AssemblyMetadataHelper.GetDispenser(); AssemblyMetadataHelper.IMetaDataAssemblyImport metaDataAssemblyImport = AssemblyMetadataHelper.OpenScope(dispenser, path); if (metaDataAssemblyImport != null) { try { AssemblyNameVersion assemblyNameVersion = AssemblyMetadataHelper.GetAssemblyNameVersion(metaDataAssemblyImport); if (assemblyNameVersion == null || !assemblyNameVersion.Name.Equals("mscorlib", StringComparison.OrdinalIgnoreCase) || !ProjectAssemblyHelper.ComparePublicKeyTokens(SilverlightProjectHelper.SilverlightPublicKeyToken, assemblyNameVersion.PublicKeyToken)) { bool flag1 = false; AssemblyNameVersion[] assemblyReferenceNameVersion = AssemblyMetadataHelper.GetAssemblyReferenceNameVersion(metaDataAssemblyImport); if (assemblyReferenceNameVersion != null) { AssemblyNameVersion[] assemblyNameVersionArray = assemblyReferenceNameVersion; int num = 0; while (num < (int)assemblyNameVersionArray.Length) { AssemblyNameVersion assemblyNameVersion1 = assemblyNameVersionArray[num]; if (!assemblyNameVersion1.Name.Equals("mscorlib", StringComparison.OrdinalIgnoreCase)) { num++; } else { flag1 = true; if (!ProjectAssemblyHelper.ComparePublicKeyTokens(SilverlightProjectHelper.SilverlightPublicKeyToken, assemblyNameVersion1.PublicKeyToken)) { break; } flag = true; return(flag); } } if (!flag1) { flag = true; return(flag); } } return(false); } else { flag = true; } } finally { if (metaDataAssemblyImport != null) { AssemblyMetadataHelper.ReleaseAssemblyImport(metaDataAssemblyImport); } if (dispenser != null) { AssemblyMetadataHelper.ReleaseDispenser(dispenser); } } return(flag); } return(false); }
public static IEnumerable <string> GetSatelliteAssemblyNames(Assembly assembly, string originalAssemblyDirectory) { return(ProjectAssemblyHelper.CopyResourceAssemblies(assembly, originalAssemblyDirectory).Reverse <string>()); }