Ejemplo n.º 1
0
        private void LoadBuiltins()
        {
            Assembly asm = typeof(IronPython.Hosting.PythonEngine).Assembly;

            object[] attributes = asm.GetCustomAttributes(typeof(PythonModuleAttribute), false);
            foreach (PythonModuleAttribute pma in attributes)
            {
                if (pma.type == typeof(IronPython.Modules.Builtin))
                {
                    global.AddType(pma.name, builtins);
                }
                else
                {
                    global.AddPythonType(pma.name, pma.type);
                }
            }
            global.AddPythonType("sys", typeof(IronPython.Runtime.SystemState));
            global.AddPythonType("clr", typeof(IronPython.Modules.ClrModule));
        }
Ejemplo n.º 2
0
        private void LoadTypes(Assembly assembly)
        {
            Type[] types = assembly.GetExportedTypes();

            foreach (Type type in types)
            {
                ReflectedModule scope = global;
                string[]        ns    = type.Namespace.Split('.');
                string          full  = "";
                bool            dot   = false;
                foreach (string n in ns)
                {
                    full  = dot ? full + "." + n : n;
                    dot   = true;
                    scope = scope.EnsureNamespace(full, SymbolTable.StringToId(n));
                }
                scope.AddType(type);
            }
        }