internal bool IsAccessibleFrom(ScriptObject scope){ //Never call this if the member is public
while (scope != null && !(scope is ClassScope))
scope = scope.GetParent();
ClassScope objType = null;
if (this.obj is ClassScope)
objType = (ClassScope)this.obj;
else
objType = (ClassScope)((ScriptObject)this.obj).GetParent();
if (this.IsPrivate)
if (scope == null)
return false;
else
return scope == objType || ((ClassScope)scope).IsNestedIn(objType, this.IsStatic);
else if (this.IsFamily)
if (scope == null)
return false;
else
return ((ClassScope)scope).IsSameOrDerivedFrom(objType) || ((ClassScope)scope).IsNestedIn(objType, this.IsStatic);
else { //if (this.IsAssembly || this.IsFamilyOrAssembly)
if (this.IsFamilyOrAssembly && scope != null &&
(((ClassScope)scope).IsSameOrDerivedFrom(objType) || ((ClassScope)scope).IsNestedIn(objType, this.IsStatic)))
return true;
else if (scope == null) //Code is not in a class and hence it is in the default package
return objType.GetPackage() == null; //null indicates default package
else
return objType.GetPackage() == ((ClassScope)scope).GetPackage();
}
}