WrapMember() static private method

static private WrapMember ( MemberInfo member, Object obj ) : MemberInfo
member System.Reflection.MemberInfo
obj Object
return System.Reflection.MemberInfo
Esempio n. 1
0
        protected static MemberInfo[] WrapMembers(MemberInfo[] members, Object obj, SimpleHashtable cache)
        {
            if (members == null)
            {
                return(null);
            }
            int n = members.Length;

            if (n == 0)
            {
                return(members);
            }
            MemberInfo[] result = new MemberInfo[n];
            for (int i = 0; i < n; i++)
            {
                MemberInfo wrappedMember = (MemberInfo)cache[members[i]];
                if (null == wrappedMember)
                {
                    wrappedMember     = ScriptObject.WrapMember(members[i], obj);
                    cache[members[i]] = wrappedMember;
                }
                result[i] = wrappedMember;
            }
            return(result);
        }
Esempio n. 2
0
        protected static MemberInfo[] WrapMembers(MemberInfo[] members, Object obj)
        {
            if (members == null)
            {
                return(null);
            }
            int n = members.Length;

            if (n == 0)
            {
                return(members);
            }
            MemberInfo[] result = new MemberInfo[n];
            for (int i = 0; i < n; i++)
            {
                result[i] = ScriptObject.WrapMember(members[i], obj);
            }
            return(result);
        }
Esempio n. 3
0
 protected static MemberInfo[] WrapMembers(MemberInfo member, Object obj)
 {
     MemberInfo[] result = new MemberInfo[1];
     result[0] = ScriptObject.WrapMember(member, obj);
     return(result);
 }
        public override MemberInfo[] GetMember(string name, BindingFlags bindingAttr)
        {
            MemberInfoList mems = new MemberInfoList();
            FieldInfo      elem = (FieldInfo)base.name_table[name];

            if (elem == null)
            {
                goto Label_0139;
            }
            if (elem.IsPublic)
            {
                if ((bindingAttr & BindingFlags.Public) != BindingFlags.Default)
                {
                    goto Label_0040;
                }
                goto Label_0139;
            }
            if ((bindingAttr & BindingFlags.NonPublic) == BindingFlags.Default)
            {
                goto Label_0139;
            }
Label_0040:
            if (!elem.IsLiteral)
            {
                goto Label_011E;
            }
            object obj2 = ((JSMemberField)elem).value;

            if (obj2 is FunctionObject)
            {
                FunctionObject obj3 = (FunctionObject)obj2;
                if (obj3.isConstructor)
                {
                    return(new MemberInfo[0]);
                }
                if (obj3.isExpandoMethod)
                {
                    if ((bindingAttr & BindingFlags.Instance) != BindingFlags.Default)
                    {
                        mems.Add(elem);
                    }
                }
                else
                {
                    ((JSMemberField)elem).AddOverloadedMembers(mems, this, bindingAttr | BindingFlags.DeclaredOnly);
                }
                goto Label_0139;
            }
            if (!(obj2 is JSProperty))
            {
                if (((obj2 is ClassScope) && ((bindingAttr & BindingFlags.Instance) != BindingFlags.Default)) && !((ClassScope)obj2).owner.isStatic)
                {
                    mems.Add(elem);
                    goto Label_0139;
                }
                goto Label_011E;
            }
            JSProperty property = (JSProperty)obj2;
            MethodInfo info2    = (property.getter != null) ? property.getter : property.setter;

            if (info2.IsStatic)
            {
                if ((bindingAttr & BindingFlags.Static) != BindingFlags.Default)
                {
                    goto Label_00EC;
                }
                goto Label_0139;
            }
            if ((bindingAttr & BindingFlags.Instance) == BindingFlags.Default)
            {
                goto Label_0139;
            }
Label_00EC:
            mems.Add(property);
            goto Label_0139;
Label_011E:
            if (elem.IsStatic)
            {
                if ((bindingAttr & BindingFlags.Static) != BindingFlags.Default)
                {
                    goto Label_0132;
                }
                goto Label_0139;
            }
            if ((bindingAttr & BindingFlags.Instance) == BindingFlags.Default)
            {
                goto Label_0139;
            }
Label_0132:
            mems.Add(elem);
Label_0139:
            if (((this.owner != null) && this.owner.isInterface) && ((bindingAttr & BindingFlags.DeclaredOnly) == BindingFlags.Default))
            {
                return(this.owner.GetInterfaceMember(name));
            }
            if ((base.parent != null) && ((bindingAttr & BindingFlags.DeclaredOnly) == BindingFlags.Default))
            {
                MemberInfo[] member = base.parent.GetMember(name, bindingAttr);
                if (member != null)
                {
                    foreach (MemberInfo info3 in member)
                    {
                        if (info3.MemberType == MemberTypes.Field)
                        {
                            elem = (FieldInfo)info3;
                            if ((!elem.IsStatic && !elem.IsLiteral) && !(elem is JSWrappedField))
                            {
                                elem = new JSWrappedField(elem, base.parent);
                            }
                            mems.Add(elem);
                        }
                        else
                        {
                            mems.Add(ScriptObject.WrapMember(info3, base.parent));
                        }
                    }
                }
            }
            return(mems.ToArray());
        }
Esempio n. 5
0
        public override MemberInfo[] GetMember(String name, BindingFlags bindingAttr)
        {
            MemberInfoList mems  = new MemberInfoList();
            FieldInfo      field = (FieldInfo)(this.name_table[name]);

            if (field != null)
            {
                if (field.IsPublic)
                {
                    if ((bindingAttr & BindingFlags.Public) == 0)
                    {
                        goto parent;
                    }
                }
                else
                {
                    if ((bindingAttr & BindingFlags.NonPublic) == 0)
                    {
                        goto parent;
                    }
                }
                if (field.IsLiteral)
                {
                    Object val = ((JSMemberField)field).value;
                    if (val is FunctionObject)
                    {
                        FunctionObject func = (FunctionObject)val;
                        if (func.isConstructor)
                        {
                            return(new MemberInfo[0]); //Suppress constructors, they are awkward to handle. The compiler always obtains them via GetConstructor
                        }
                        if (func.isExpandoMethod)
                        {
                            if ((bindingAttr & BindingFlags.Instance) == 0)
                            {
                                goto parent;
                            }
                            mems.Add(field);
                        }
                        else
                        {
                            ((JSMemberField)field).AddOverloadedMembers(mems, this, bindingAttr | BindingFlags.DeclaredOnly);
                        }
                        goto parent;
                    }
                    else if (val is JSProperty)
                    {
                        JSProperty prop           = (JSProperty)val;
                        MethodInfo getterOrSetter = prop.getter != null ? prop.getter : prop.setter;
                        if (getterOrSetter.IsStatic)
                        {
                            if ((bindingAttr & BindingFlags.Static) == 0)
                            {
                                goto parent;
                            }
                        }
                        else
                        {
                            if ((bindingAttr & BindingFlags.Instance) == 0)
                            {
                                goto parent;
                            }
                        }
                        mems.Add(prop);
                        goto parent;
                    }
                    else if (val is ClassScope)
                    {
                        if ((bindingAttr & BindingFlags.Instance) != 0)
                        {
                            if (!((ClassScope)val).owner.isStatic)
                            {
                                mems.Add(field);
                                goto parent;
                            }
                        }
                    }
                }
                if (field.IsStatic)
                {
                    if ((bindingAttr & BindingFlags.Static) == 0)
                    {
                        goto parent;
                    }
                }
                else
                {
                    if ((bindingAttr & BindingFlags.Instance) == 0)
                    {
                        goto parent;
                    }
                }
                mems.Add(field);
            }
parent:
            if (this.owner != null && this.owner.isInterface && ((bindingAttr & BindingFlags.DeclaredOnly) == 0))
            {
                return(this.owner.GetInterfaceMember(name));
            }
            if (this.parent != null && ((bindingAttr & BindingFlags.DeclaredOnly) == 0)) //Add any members found on the superclass
            {
                MemberInfo[] supMembers = this.parent.GetMember(name, bindingAttr);
                if (supMembers != null)
                {
                    foreach (MemberInfo mem in supMembers)
                    {
                        if (mem.MemberType == MemberTypes.Field)
                        {
                            field = (FieldInfo)mem;
                            if (!field.IsStatic && !field.IsLiteral && !(field is JSWrappedField))
                            {
                                field = new JSWrappedField(field, this.parent);
                            }
                            mems.Add(field);
                        }
                        else
                        {
                            mems.Add(ScriptObject.WrapMember(mem, this.parent));
                        }
                    }
                }
            }
            return(mems.ToArray());
        }