internal IMember MakeObject(object obj) { if (obj == null) { return(null); } lock (this) { IMember res; if (!_members.TryGetValue(obj, out res)) { PythonModule mod = obj as PythonModule; if (mod != null) { // FIXME: name object name; if (!mod.Get__dict__().TryGetValue("__name__", out name) || !(name is string)) { name = ""; } _members[obj] = res = new IronPythonModule(this, mod, (string)name); } PythonType type = obj as PythonType; if (type != null) { _members[obj] = res = GetTypeFromType(type.__clrtype__()); } BuiltinFunction func = obj as BuiltinFunction; if (func != null) { _members[obj] = res = new IronPythonBuiltinFunction(this, func); } BuiltinMethodDescriptor methodDesc = obj as BuiltinMethodDescriptor; if (methodDesc != null) { _members[obj] = res = new IronPythonBuiltinMethodDescriptor(this, methodDesc); } ReflectedField field = obj as ReflectedField; if (field != null) { return(new IronPythonField(this, field)); } ReflectedProperty prop = obj as ReflectedProperty; if (prop != null) { _members[obj] = res = new IronPythonProperty(this, prop); } ReflectedExtensionProperty extProp = obj as ReflectedExtensionProperty; if (extProp != null) { _members[obj] = res = new IronPythonExtensionProperty(this, extProp); } NamespaceTracker ns = obj as NamespaceTracker; if (ns != null) { _members[obj] = res = new IronPythonNamespace(this, ns); } Method method = obj as Method; if (method != null) { _members[obj] = res = new IronPythonGenericMember(this, method, PythonMemberType.Method); } var classMethod = obj as ClassMethodDescriptor; if (classMethod != null) { _members[obj] = res = new IronPythonGenericMember(this, classMethod, PythonMemberType.Method); } var typeSlot = obj as PythonTypeTypeSlot; if (typeSlot != null) { _members[obj] = res = new IronPythonGenericMember(this, typeSlot, PythonMemberType.Property); } ReflectedEvent eventObj = obj as ReflectedEvent; if (eventObj != null) { return(new IronPythonEvent(this, eventObj)); } if (res == null) { var genericTypeSlot = obj as PythonTypeSlot; if (genericTypeSlot != null) { _members[obj] = res = new IronPythonGenericMember(this, genericTypeSlot, PythonMemberType.Property); } } TypeGroup tg = obj as TypeGroup; if (tg != null) { _members[obj] = res = new PythonObject <TypeGroup>(this, tg); } var attrType = (obj != null) ? obj.GetType() : typeof(DynamicNull); if (attrType == typeof(bool) || attrType == typeof(int) || attrType == typeof(Complex) || attrType == typeof(string) || attrType == typeof(long) || attrType == typeof(double) || attrType.IsEnum || obj == null) { _members[obj] = res = new IronPythonConstant(this, obj); } if (res == null) { Debug.Assert(!(obj is bool)); _members[obj] = res = new PythonObject <object>(this, obj); } } return(res); } }