static AssemblyNameComparerFlags ToAssemblyNameComparerFlags(FindAssemblyOptions options) { AssemblyNameComparerFlags flags = 0; if ((options & FindAssemblyOptions.Name) != 0) { flags |= AssemblyNameComparerFlags.Name; } if ((options & FindAssemblyOptions.Version) != 0) { flags |= AssemblyNameComparerFlags.Version; } if ((options & FindAssemblyOptions.PublicKeyToken) != 0) { flags |= AssemblyNameComparerFlags.PublicKeyToken; } if ((options & FindAssemblyOptions.Culture) != 0) { flags |= AssemblyNameComparerFlags.Culture; } if ((options & FindAssemblyOptions.ContentType) != 0) { flags |= AssemblyNameComparerFlags.ContentType; } return(flags); }
public IDsDocument?FindAssembly(IAssembly assembly, FindAssemblyOptions options) { var flags = ToAssemblyNameComparerFlags(options); var comparer = new AssemblyNameComparer(flags); rwLock.EnterReadLock(); try { foreach (var info in documents) { if (comparer.Equals(info.Document.AssemblyDef, assembly)) { return(info.Document); } } foreach (var info in documents) { if (info.IsAlternativeAssemblyName(assembly)) { return(info.Document); } } } finally { rwLock.ExitReadLock(); } lock (tempCacheLock) { foreach (var document in tempCache) { if (comparer.Equals(document.AssemblyDef, assembly)) { return(document); } } } return(null); }