Beispiel #1
0
        public static void BeginLoadAssemblyInformations(LoadAssemblyUpdateEventHandler updateHandler, int resultSize, string netRuntimeCondition = "NET_4_0")
        {
            RunAsyncMethod(
                delegate
            {
                GACAssemblies list = new GACAssemblies();

                AssemblyCacheEnum cache = new AssemblyCacheEnum(null);
                string assemblyString   = cache.GetNextAssembly();

                string assemblyName = string.Empty;
                if (!String.IsNullOrEmpty(assemblyString))
                {
                    GACAssembly gacAssembly = QueryAssemblyInfo(assemblyString);
                    if (CheckConditions(gacAssembly, netRuntimeCondition))
                    {
                        list.Add(gacAssembly);
                    }
                }
                else
                {
                    updateHandler(list.ToArray(), true);
                    return;
                }

                while (null != assemblyString)
                {
                    assemblyString = cache.GetNextAssembly();
                    if (!String.IsNullOrEmpty(assemblyString))
                    {
                        GACAssembly gacAssembly = QueryAssemblyInfo(assemblyString);
                        if (!CheckConditions(gacAssembly, netRuntimeCondition))
                        {
                            continue;
                        }
                        list.Add(gacAssembly);
                    }

                    if (list.Count >= resultSize)
                    {
                        updateHandler(list.ToArray(), false);
                        list.Clear();
                    }
                }

                updateHandler(list.ToArray(), true);
                list.Clear();
            });
        }
Beispiel #2
0
        public static GACAssemblies LoadAssemblyInformations(bool sortAlphabetically = true, string netRuntimeCondition = "NET_4_0")
        {
            GACAssemblies list = new GACAssemblies();

            AssemblyCacheEnum cache          = new AssemblyCacheEnum(null);
            string            assemblyString = cache.GetNextAssembly();

            string assemblyName = string.Empty;

            if (!String.IsNullOrEmpty(assemblyString))
            {
                GACAssembly gacAssembly = QueryAssemblyInfo(assemblyString);
                if (CheckConditions(gacAssembly, netRuntimeCondition))
                {
                    list.Add(gacAssembly);
                }
            }
            else
            {
                return(list);
            }

            while (null != assemblyString)
            {
                assemblyString = cache.GetNextAssembly();
                if (!String.IsNullOrEmpty(assemblyString))
                {
                    GACAssembly gacAssembly = QueryAssemblyInfo(assemblyString);
                    if (!CheckConditions(gacAssembly, netRuntimeCondition))
                    {
                        continue;
                    }
                    list.Add(gacAssembly);
                }
            }

            if (sortAlphabetically)
            {
                list.Sort(new GACAssemblyComparer());
            }

            return(list);
        }