private GlobalContext() : base(null) { Dictionary<string,NSPrototype> ns = new Dictionary<string, NSPrototype>(); foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { foreach (var type in assembly.GetTypes()) { var current = ns; if (type.Namespace == null) continue; foreach (string component in type.Namespace.Split('.')) { if (current.ContainsKey(component)) { current = current[component].Entries; } else { var ent = new NSPrototype(); current[component] = ent; current = ent.Entries; } } } } // Load the top-level namespaces foreach (var kvp in ns) SetVariable(kvp.Key, STNamespace.Build(kvp.Key, kvp.Value)); }
public static STNamespace Build(string name, NSPrototype prototype) { var ns = new STNamespace(name, name); ns.Build (prototype.Entries); return ns; }