public override void RemoveEventHandler(object component, Delegate value) {
FillMethods();
if (component != null) {
ISite site = GetSite(component);
IComponentChangeService changeService = null;
// Announce that we are about to change this component
//
if (site != null) {
changeService = (IComponentChangeService)site.GetService(typeof(IComponentChangeService));
Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || changeService != null, "IComponentChangeService not found");
}
if (changeService != null) {
try {
changeService.OnComponentChanging(component, this);
}
catch (CheckoutException coEx) {
if (coEx == CheckoutException.Canceled) {
return;
}
throw coEx;
}
}
bool shadowed = false;
if (site != null && site.DesignMode) {
IDictionaryService dict = (IDictionaryService)site.GetService(typeof(IDictionaryService));
Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || dict != null, "IDictionaryService not found");
if (dict != null) {
Delegate del = (Delegate)dict.GetValue(this);
del = Delegate.Remove(del, value);
dict.SetValue(this, del);
shadowed = true;
}
}
if (!shadowed) {
removeMethod.Invoke(component, new object[] { value});
}
// Now notify the change service that the change was successful.
//
if (changeService != null) {
changeService.OnComponentChanged(component, this, null, value);
}
}
}