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));
}
if (changeService != null)
{
try {
changeService.OnComponentChanging(component, this);
}
catch (CheckoutException coEx) {
if (coEx == CheckoutException.Canceled) {
return;
}
throw coEx;
}
changeService.OnComponentChanging(component, this);
}
bool shadowed = false;
if (site != null && site.DesignMode)
{
IDictionaryService dict = (IDictionaryService)site.GetService(typeof(IDictionaryService));
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[] { value });
}
// Now notify the change service that the change was successful.
//
if (changeService != null)
{
changeService.OnComponentChanged(component, this, null, value);
}
}
}
}