public DaElement FindElement(string itemId)
{
if (String.IsNullOrEmpty(itemId))
{
return null;
}
// check the cache.
DaElement element = null;
lock (m_cache)
{
if (m_cache.TryGetValue(itemId, out element))
{
return element;
}
}
// try extracting the name by parsing the item id.
string name = null;
if (m_configuration.ItemIdParser.Parse(this, m_configuration, itemId, out name))
{
element = CreateElement(itemId, name, null);
}
// need to do it the hard way by searching the address space.
else
{
IDaElementBrowser browser = CreateBrowser(itemId);
element = browser.Find(itemId, false);
browser.Dispose();
}
// save element in the cache.
if (element != null)
{
SaveElementInCache(element);
}
return element;
}