/// <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)
        {
            Type fusionType;
            if (string.IsNullOrEmpty(FusionAssemblyName))
            {
                fusionType = InitialiseFusion(DefaultFusionAssemblyName);
            }
            else
            {
                fusionType = InitialiseFusion(FusionAssemblyName);
            }

            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;
        }
 private bool AssemblyShouldBeRemoved(GlobalAssemblyCacheItem globalAssemblyCacheItem)
 {
     bool shouldBeRemoved = AssemblyIdComponentMatches(globalAssemblyCacheItem.Name, this.AssemblyName) &&
                            AssemblyIdComponentMatches(globalAssemblyCacheItem.Version, this.Version) &&
                            AssemblyIdComponentMatches(globalAssemblyCacheItem.Locale, this.Locale) &&
                            AssemblyIdComponentMatches(globalAssemblyCacheItem.PublicKeyToken, this.PublicKeyToken);
     return shouldBeRemoved;
 }
 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);
 }