// The number of frames to skip depends on who's calling
// - CodeAccessPermission.Demand (imperative)
// - PermissionSet.Demand (imperative)
// - SecurityManager.InternalDemand (declarative)
internal void CasOnlyDemand(int skip)
{
Assembly current = null;
AppDomain domain = null;
if (_ignored == null)
{
// special case when directly called from CodeAccessPermission.Demand
_ignored = new bool [list.Count];
}
ArrayList frames = SecurityFrame.GetStack(skip);
if ((frames != null) && (frames.Count > 0))
{
SecurityFrame first = ((SecurityFrame)frames [0]);
current = first.Assembly;
domain = first.Domain;
// skip ourself, Demand and other security runtime methods
foreach (SecurityFrame sf in frames)
{
if (ProcessFrame(sf, ref current, ref domain))
{
if (AllIgnored())
{
return; // reached Assert
}
}
}
SecurityFrame last = ((SecurityFrame)frames [frames.Count - 1]);
CheckAssembly(current, last);
CheckAppDomain(domain, last);
}
// Is there a CompressedStack to handle ?
CompressedStack stack = Thread.CurrentThread.GetCompressedStack();
if ((stack != null) && !stack.IsEmpty())
{
foreach (SecurityFrame frame in stack.List)
{
if (ProcessFrame(frame, ref current, ref domain))
{
if (AllIgnored())
{
return; // reached Assert
}
}
}
}
}