scriptsharp icon indicating copy to clipboard operation
scriptsharp copied to clipboard

MultiCastDelegate InvocationList

Open dax70 opened this issue 14 years ago • 0 comments

Without exposing the invocation list, things like CancelEventArgs or wrapping jQueryEvent or DomEvent is nearly impossible.

public class MultiCastDelegate
{
    // Missing from S# implementation
    public sealed override Delegate[] GetInvocationList();
}

Needed for 'Cancelable' patterns.

protected internal void OnItemClick(ItemClickEventArgs e)
{
    bool cancel = false;
    EventHandler<ItemClickEventArgs> handler = this.ItemClick;
    if (handler != null)
    {
        foreach (EventHandler<ItemClickEventArgs> subscriber in handler.GetInvocationList())
        {
            subscriber(this, args);
            if (args.Cancel)
            {
                cancel = true;
                break;
            }
        }
    }
    if (!cancel) { /* ... */ }
}

dax70 avatar Jan 10 '12 06:01 dax70