GetAllAvailableAssemblies() private method

private GetAllAvailableAssemblies ( ) : List
return List
Beispiel #1
0
            private void Populate()
            {
                bool populate;

                lock (entries)
                {
                    populate = entries.Count == 0;
                }
                if (populate)
                {
                    Dictionary <string, string> names = new Dictionary <string, string>();
                    AssemblyClassLoader         acl   = AssemblyClassLoader.FromAssembly(this.asm);
                    foreach (Assembly asm in acl.GetAllAvailableAssemblies())
                    {
                        Type[] types;
                        try
                        {
                            types = asm.GetTypes();
                        }
                        catch (ReflectionTypeLoadException x)
                        {
                            types = x.Types;
                        }
                        catch
                        {
                            types = Type.EmptyTypes;
                        }
                        foreach (Type type in types)
                        {
                            if (type != null)
                            {
                                string name = null;
                                try
                                {
                                    bool isJavaType;
                                    name = acl.GetTypeNameAndType(type, out isJavaType);
#if !FIRST_PASS
                                    // annotation custom attributes are pseudo proxies and are not loadable by name (and should not exist in the file systems,
                                    // because proxies are, ostensibly, created on the fly)
                                    if (isJavaType && type.BaseType == typeof(global::[email protected]) && name.Contains(".$Proxy"))
                                    {
                                        name = null;
                                    }
#endif
                                }
                                catch
                                {
                                }
                                if (name != null)
                                {
                                    names[name] = name;
                                }
                            }
                        }
                    }
                    lock (entries)
                    {
                        if (entries.Count == 0)
                        {
                            foreach (string name in names.Keys)
                            {
                                string[]     parts = name.Split('.');
                                VfsDirectory dir   = this;
                                for (int i = 0; i < parts.Length - 1; i++)
                                {
                                    dir = dir.GetEntry(parts[i]) as VfsDirectory ?? dir.AddDirectory(parts[i]);
                                }
                                // we're adding a dummy file, to make the file appear in the directory listing, it will not actually
                                // be accessed, because the code above handles that
                                dir.Add(parts[parts.Length - 1] + ".class", VfsDummyFile.Instance);
                            }
                        }
                    }
                }
            }