private ICmObject GetCurrentCmObject()
{
ICmObject obj = null;
if (m_hostControl is XmlBrowseViewBase && !m_hostControl.IsDisposed)
{
// since we're getting the context menu by clicking on the browse view
// just use the current object of the browse view.
// NOTE: This helps to bypass a race condition that occurs when the user
// right-clicks on a record that isn't (yet) the current record.
// In that case RecordBrowseView establishes the new index before
// calling HandleRightClick to create the context menu, but
// presently, "ActiveClerkSelectedObject" only gets established on Idle()
// AFTER the context menu is created. (A side effect of LT-9192, LT-8874,
// XmlBrowseViewBase.FireSelectionChanged)
// To get around this, we must use the CurrentObject
// directly from the Browse view.
int hvoCurrentObject = (m_hostControl as XmlBrowseViewBase).SelectedObject;
if (hvoCurrentObject != 0)
obj = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>().GetObject(hvoCurrentObject);
}
else
{
obj = m_mediator.PropertyTable.GetValue("ActiveClerkSelectedObject", null) as ICmObject;
}
return obj;
}