TryGetValue() private method

private TryGetValue ( CodeContext context, object instance, IronPython.Runtime.Types.PythonType owner, object &value ) : bool
context CodeContext
instance object
owner IronPython.Runtime.Types.PythonType
value object
return bool
Esempio n. 1
0
        internal static object GetOldStyleDescriptor(CodeContext context, object self, object instance, PythonType type)
        {
            PythonTypeSlot dts = self as PythonTypeSlot;
            object         callable;

            if (dts != null && dts.TryGetValue(context, instance, type, out callable))
            {
                return(callable);
            }

            return(PythonOps.GetUserDescriptor(self, instance, type));
        }
        internal object GetValue(CodeContext context, object instance, PythonType owner)
        {
            if (_descVersion == UserDescriptorFalse)
            {
                return(_value);
            }
            else if (_descVersion != DynamicHelpers.GetPythonType(_value).Version)
            {
                CalculateDescriptorInfo();
                if (_descVersion == UserDescriptorFalse)
                {
                    return(_value);
                }
            }

            object res;

            Debug.Assert(_desc.GetAlwaysSucceeds);
            _desc.TryGetValue(context, _value, DynamicHelpers.GetPythonType(_value), out res);
            return(PythonContext.GetContext(context).Call(context, res, instance, owner));
        }