F
Filippo P.
Hi there,
I have a menu (Collection) that needs to be trimmed based on security access
of the
logged user.
protected void AdjustMenuBasedOnUserSecurity(Items ItemsList)
{
foreach (Item i in ItemsList)
{
if (i.Items.Count > 0)
AdjustMenuBasedOnUserSecurity(i.Items);
if (i.Tag == null)
continue;
if (this.LoggedUser.HasPermission(Convert.ToInt32(i.Tag)) == false)
ItemsList.RemoveAt(i.Index);
}
}
=======================
PROBLEM
Altought this proc is recursive, the FOREACH seems to not recalculate the
COUNT of the Items Collection at every run, so when I remove an item from
the list, I also pretty much screws the internal COUNT of the FOREACH.
=======================
SOLUTION
...hummm here is where you may put add some ideas... !!!
Thanks,
Filippo
I have a menu (Collection) that needs to be trimmed based on security access
of the
logged user.
protected void AdjustMenuBasedOnUserSecurity(Items ItemsList)
{
foreach (Item i in ItemsList)
{
if (i.Items.Count > 0)
AdjustMenuBasedOnUserSecurity(i.Items);
if (i.Tag == null)
continue;
if (this.LoggedUser.HasPermission(Convert.ToInt32(i.Tag)) == false)
ItemsList.RemoveAt(i.Index);
}
}
=======================
PROBLEM
Altought this proc is recursive, the FOREACH seems to not recalculate the
COUNT of the Items Collection at every run, so when I remove an item from
the list, I also pretty much screws the internal COUNT of the FOREACH.
=======================
SOLUTION
...hummm here is where you may put add some ideas... !!!
Thanks,
Filippo