Exemplo n.º 1
0
        /// <summary>
        /// Gets a list of items in the GAC.
        /// </summary>
        /// <param name="globalAssemblyCacheCategory">The category.</param>
        /// <returns>An array of <see cref="GlobalAssemblyCacheItem"/>. The items in the GAC.</returns>
        public static GlobalAssemblyCacheItem[] GetAssemblyList(GlobalAssemblyCacheCategoryTypes globalAssemblyCacheCategory)
        {
            ArrayList assemblyInfoList = new ArrayList();
            object[] args = new object[] { assemblyInfoList, (uint)globalAssemblyCacheCategory };
            const BindingFlags BindingFlags = (BindingFlags)314;
            fusionType.InvokeMember("ReadCache", BindingFlags, null, null, args, CultureInfo.CurrentCulture);
            GlobalAssemblyCacheItem[] gacAssemblies = new GlobalAssemblyCacheItem[assemblyInfoList.Count];
            for (int i = 0; i < assemblyInfoList.Count; i++)
            {
                string name = (string)GetField(assemblyInfoList[i], "Name");
                string locale = (string)GetField(assemblyInfoList[i], "Locale");
                string publicKeyToken = (string)GetField(assemblyInfoList[i], "PublicKeyToken");
                string version = (string)GetField(assemblyInfoList[i], "Version");
                gacAssemblies[i] = new GlobalAssemblyCacheItem(name, version, locale, publicKeyToken);
            }

            return gacAssemblies;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Determines if assemblies should be removed.
        /// </summary>
        /// <param name="globalAssemblyCacheItem">The global assembly cache item.</param>
        /// <returns>Indicating if the assemblies should be removed.</returns>
        private bool AssemblyShouldBeRemoved(GlobalAssemblyCacheItem globalAssemblyCacheItem)
        {
            bool shouldBeRemoved = false;
            if (AssemblyIdComponentMatches(globalAssemblyCacheItem.Name, this.AssemblyName) &&
                AssemblyIdComponentMatches(globalAssemblyCacheItem.Version, this.Version) &&
                AssemblyIdComponentMatches(globalAssemblyCacheItem.Locale, this.Locale) &&
                AssemblyIdComponentMatches(globalAssemblyCacheItem.PublicKeyToken, this.PublicKeyToken))
            {
                shouldBeRemoved = true;
            }

            return shouldBeRemoved;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Gets a fully qualified Assembly name.
 /// </summary>
 /// <param name="globalAssemblyCacheItem">The item in the GAC.</param>
 /// <returns>The fully qualified name.</returns>
 private static string GetFullyQualifiedAssemblyName(GlobalAssemblyCacheItem globalAssemblyCacheItem)
 {
     return string.Format(CultureInfo.CurrentCulture, "{0},Version={1},Culture={2},PublicKeyToken={3}", globalAssemblyCacheItem.Name, globalAssemblyCacheItem.Version, globalAssemblyCacheItem.Locale, globalAssemblyCacheItem.PublicKeyToken);
 }