예제 #1
0
        internal override bool TryGetValue(CodeContext context, object instance, PythonType owner, out object value)
        {
            if (instance == null)
            {
                value = this;
                return(true);
            }

            IProxyObject proxy = instance as IProxyObject;

            if (proxy == null)
            {
                throw PythonOps.TypeError("descriptor for {0} object doesn't apply to {1} object",
                                          PythonOps.Repr(context, _type.Name),
                                          PythonOps.Repr(context, PythonTypeOps.GetName(instance)));
            }

            if (!DynamicHelpers.GetPythonType(proxy.Target).TryGetBoundMember(context, proxy.Target, _name, out value))
            {
                return(false);
            }

            value = new GenericMethodWrapper(_name, proxy);
            return(true);
        }
예제 #2
0
        internal override bool TryGetValue(CodeContext context, object instance, PythonType owner, out object value) {
            if (instance == null) {
                value = this;
                return true;
            }

            IProxyObject proxy = instance as IProxyObject;

            if (proxy == null)
                throw PythonOps.TypeError("descriptor for {0} object doesn't apply to {1} object",
                    PythonOps.Repr(context, type.Name),
                    PythonOps.Repr(context, PythonTypeOps.GetName(instance)));

            if (!DynamicHelpers.GetPythonType(proxy.Target).TryGetBoundMember(context, proxy.Target, name, out value))
                return false;

            value = new GenericMethodWrapper(name, proxy);
            return true;
        }