GetValue() private method

private GetValue ( Object obj, BindingFlags invokeAttr, Binder binder, Object index, CultureInfo culture ) : Object
obj Object
invokeAttr BindingFlags
binder Binder
index Object
culture System.Globalization.CultureInfo
return Object
Example #1
0
        internal static object GetValue(PropertyInfo prop, object obj, object[] index)
        {
            JSProperty property = prop as JSProperty;

            if (property != null)
            {
                return(property.GetValue(obj, BindingFlags.ExactBinding, null, index, null));
            }
            JSWrappedProperty property2 = prop as JSWrappedProperty;

            if (property2 != null)
            {
                return(property2.GetValue(obj, BindingFlags.ExactBinding, null, index, null));
            }
            MethodInfo getMethod = GetGetMethod(prop, false);

            if (getMethod != null)
            {
                try
                {
                    return(getMethod.Invoke(obj, BindingFlags.ExactBinding, null, index, null));
                }
                catch (TargetInvocationException exception)
                {
                    throw exception.InnerException;
                }
            }
            throw new MissingMethodException();
        }
        internal override object GetMemberValue(string name)
        {
            object memberValue = Microsoft.JScript.Missing.Value;

            if (!this.recursive)
            {
                this.recursive = true;
                try
                {
                    FieldInfo field = this.reflectObj.GetField(name, BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
                    if (field == null)
                    {
                        PropertyInfo property = this.reflectObj.GetProperty(name, BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
                        if (property != null)
                        {
                            memberValue = JSProperty.GetValue(property, this.namedItem, null);
                        }
                    }
                    else
                    {
                        memberValue = field.GetValue(this.namedItem);
                    }
                    if ((memberValue is Microsoft.JScript.Missing) && (base.parent != null))
                    {
                        memberValue = base.parent.GetMemberValue(name);
                    }
                }
                finally
                {
                    this.recursive = false;
                }
            }
            return(memberValue);
        }
Example #3
0
        internal override Object GetMemberValue(String name)
        {
            Object retValue = Missing.Value;

            if (!this.recursive)
            {
                this.recursive = true;
                try{
                    FieldInfo field = this.reflectObj.GetField(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy | BindingFlags.Public);
                    if (field == null)
                    {
                        PropertyInfo prop = this.reflectObj.GetProperty(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.FlattenHierarchy | BindingFlags.Public);
                        if (prop != null)
                        {
                            retValue = JSProperty.GetValue(prop, this.namedItem, null);
                        }
                    }
                    else
                    {
                        retValue = field.GetValue(this.namedItem);
                    }

                    if (retValue is Missing && null != parent)
                    {
                        retValue = parent.GetMemberValue(name);
                    }
                }finally{
                    this.recursive = false;
                }
            }
            return(retValue);
        }
Example #4
0
        internal static Object GetValue(PropertyInfo prop, Object obj, Object[] index)
        {
            JSProperty jsprop = prop as JSProperty;

            if (jsprop != null)
            {
                return(jsprop.GetValue(obj, BindingFlags.ExactBinding, null, index, null));
            }
            JSWrappedProperty jswrappedprop = prop as JSWrappedProperty;

            if (jswrappedprop != null)
            {
                return(jswrappedprop.GetValue(obj, BindingFlags.ExactBinding, null, index, null));
            }
            MethodInfo meth = JSProperty.GetGetMethod(prop, false);

            if (meth != null)
            {
                return(meth.Invoke(obj, BindingFlags.ExactBinding, null, index, null));
            }
            throw new MissingMethodException();
        }