private AeBrowseElement FindRoot(string itemId, Stack<string> names)
{
// parse the item id looking for a known parent.
AeBrowseElement root = null;
string currentId = itemId;
while (!String.IsNullOrEmpty(currentId))
{
string parentId = null;
string itemName = currentId;
int index = currentId.LastIndexOf('/');
if (index >= 0)
{
parentId = currentId.Substring(0, index);
itemName = currentId.Substring(index + 1);
}
// save time by using an intermediate parent if it has already been cached.
if (!String.IsNullOrEmpty(parentId))
{
if (m_cache.TryGetValue(parentId, out root))
{
names.Push(itemName);
break;
}
}
currentId = parentId;
names.Push(itemName);
root = null;
}
if (root == null)
{
root = m_cache[String.Empty];
}
return root;
}