static void EnsureNamespaceList() { if (allNodes != null) { return; } typeToNode = new Dictionary <Type, NamespaceWrapper>(); allNodes = new Dictionary <string, NamespaceWrapper>(); foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) { foreach (Type t in a.GetTypes()) { if (t.IsSpecialName) { continue; } if (t.IsGenericType) { continue; } if (t.IsGenericTypeDefinition) { continue; } else { if (t.IsGenericType) { continue; } } if (t.IsInterface) { continue; } if (!t.IsVisible) { continue; } var p = t.FullName; if (!t.IsGenericTypeDefinition && p.IndexOfAny(SpecialChars) != -1) { continue; } var node = NamespaceWrapper.MakeType(t); allNodes[node.path] = node; typeToNode[node.type] = node; } } foreach (var k in allNodes.Keys.ToArray()) { var node = allNodes[k]; RegisterTypeNode(node); } }
public static void ClearCache() { NamespaceWrapper.ClearCache(); TypeWrapper.ClearCache(); GenericWrapper.ClearCache(); DelegateWrapper.ClearCache(); InstanceMethodWrapper.ClearCache(); StaticMethodWrapper.ClearCache(); ConstructorWrapper.ClearCache(); }
static NamespaceWrapper MakeNamespace(string path) { var p = path; p = p.Replace('+', '.'); var node = new NamespaceWrapper(); node.type = null; node.isType = false; node.path = p; var idx = p.LastIndexOf('.'); node.name = idx == -1 ? p : p.Substring(idx + 1); return(node); }
static void RegisterTypeNode(NamespaceWrapper target) { var t = target.type; var node = target; var path = target.path; while (true) { bool finish = false; string parentPath, name; var idx = path.LastIndexOf('.'); if (idx == -1) { finish = true; name = path; parentPath = ""; } else { parentPath = path.Substring(0, idx); name = path.Substring(idx + 1); } NamespaceWrapper parentNode; if (!allNodes.TryGetValue(parentPath, out parentNode)) { parentNode = NamespaceWrapper.MakeNamespace(parentPath); allNodes[parentPath] = parentNode; } if (parentNode.children == null) { parentNode.children = new Dictionary <string, NamespaceWrapper>(); } if (!parentNode.children.ContainsKey(name)) { parentNode.children[name] = node; } node.parent = parentNode; if (finish) { break; } path = parentPath; node = parentNode; } }
static NamespaceWrapper MakeType(Type t) { var p = t.FullName; if (t.IsGenericTypeDefinition) { p = p.Substring(0, p.IndexOf('`')); } //Console.WriteLine(p); p = p.Replace('+', '.'); var node = new NamespaceWrapper(); node.type = t; node.isType = true; node.path = p; var idx = p.LastIndexOf('.'); node.name = idx == -1 ? p : p.Substring(idx + 1); return(node); }
public static JavaScriptValue WrapNamespace(string path) { var c = NamespaceWrapper.Get(path); return(c.GetJavaScriptValue()); }
public PropertyProxy(NamespaceWrapper node) { this.node = node; thisPtr = GCHandle.Alloc(this); }