private MemberInfo[] GetMember(String name, BindingFlags bindingAttr, bool calledFromParent)
{
if (this.recursive)
{
return(new MemberInfo[0]);
}
MemberInfo[] result = null;
if (!this.isComponentScope)
{
//Look for an expando
MemberInfo[] members = base.GetMember(name, bindingAttr | BindingFlags.DeclaredOnly);
if (members.Length > 0)
{
return(members);
}
if (this.componentScopes != null)
{
for (int i = 0, n = this.componentScopes.Count; i < n; i++)
{
GlobalScope sc = (GlobalScope)this.componentScopes[i];
result = sc.GetMember(name, bindingAttr | BindingFlags.DeclaredOnly, true);
if (result.Length > 0)
{
return(result);
}
}
}
if (this.globalObject != null)
{
result = this.globalObjectTR.GetMember(name, bindingAttr & ~BindingFlags.NonPublic | BindingFlags.Static);
}
if (result != null && result.Length > 0)
{
return(ScriptObject.WrapMembers(result, this.globalObject));
}
}
else
{
//Look for global variables represented as static fields on subclass of GlobalScope. I.e. the script block case.
result = this.typeReflector.GetMember(name, bindingAttr & ~BindingFlags.NonPublic | BindingFlags.Static);
int n = result.Length;
if (n > 0)
{
int toBeHidden = 0;
MemberInfo[] newResult = new MemberInfo[n];
for (int i = 0; i < n; i++)
{
MemberInfo mem = newResult[i] = result[i];
if (mem.DeclaringType.IsAssignableFrom(Typeob.GlobalScope))
{
newResult[i] = null; toBeHidden++;
}
else if (mem is FieldInfo)
{
FieldInfo field = (FieldInfo)mem;
if (field.IsStatic && field.FieldType == Typeob.Type)
{
Type t = (Type)field.GetValue(null);
if (t != null)
{
newResult[i] = t;
}
}
}
}
if (toBeHidden == 0)
{
return(result);
}
if (toBeHidden == n)
{
return(new MemberInfo[0]);
}
MemberInfo[] remainingMembers = new MemberInfo[n - toBeHidden];
int j = 0;
foreach (MemberInfo mem in newResult)
{
if (mem != null)
{
remainingMembers[j++] = mem;
}
}
return(remainingMembers);
}
}
if (this.parent != null && !calledFromParent && ((bindingAttr & BindingFlags.DeclaredOnly) == 0 || this.isComponentScope))
{
this.recursive = true;
try
{
result = ((ScriptObject)this.parent).GetMember(name, bindingAttr);
}
finally
{
this.recursive = false;
}
if (result != null && result.Length > 0)
{
return(result);
}
}
return(new MemberInfo[0]);
}