private IPropertyEditingContext GetContext() { // first try to get a client-defined IPropertyEditingContext IPropertyEditingContext context = ContextRegistry.GetMostRecentContext <IPropertyEditingContext>(); if (context != null) { m_defaultContext.SelectionContext = null; } else { // otherwise, try to get a client-defined ISelectionContext and adapt it ISelectionContext selectionContext = ContextRegistry.GetMostRecentContext <ISelectionContext>(); m_defaultContext.SelectionContext = selectionContext; if (selectionContext != null) { context = m_defaultContext; } } return(context); }