public UserInterfaceContainer( Outlook.Inspector inspector, Office.Core.CustomTaskPane taskPane, IRibbonConnector ribbonConnector) { if (inspector != null) { _inspector = inspector; _taskPane = taskPane; _ribbonConnector = ribbonConnector; // 接收 InspectorClose 事件以便我们能够进行清理。 _inspectorEvents = (Outlook.InspectorEvents_10_Event)_inspector; _inspectorEvents.Close += new Outlook.InspectorEvents_10_CloseEventHandler( _inspectorEvents_Close); } }
void _inspectorEvents_Close() { // 将我们自身从 UI 对象集合中移除, // 解除挂钩关闭事件,然后清理所有引用。 _inspectorEvents.Close -= new Outlook.InspectorEvents_10_CloseEventHandler( _inspectorEvents_Close); if (InspectorClose != null) { // 告诉所有侦听方我们正在关闭。 InspectorClose(this, new EventArgs()); } _inspector = null; _inspectorEvents = null; _taskPane = null; _formRegionControls = null; _ribbonConnector = null; }