DelegateHelper

Ecng.Common

Provides helper methods for working with delegates.

Methods

AddDelegate``1
public static TDelegate AddDelegate<TDelegate>(TDelegate source, TDelegate value)
result = DelegateHelper.AddDelegate(source, value)

Combines two delegates of the same type.

source
The source delegate.
value
The delegate to combine with the source delegate.

Returns: A combined delegate of type .

CreateDelegate``1
public static TDelegate CreateDelegate<TDelegate>(MethodInfo method)
result = DelegateHelper.CreateDelegate(method)

Creates a delegate of type for the specified method.

method
The method information.

Returns: A delegate of type .

CreateDelegate``2
public static TDelegate CreateDelegate<TInstance, TDelegate>(MethodInfo method, TInstance instance)
result = DelegateHelper.CreateDelegate(method, instance)

Creates a delegate of type for the specified method and instance.

method
The method information.
instance
The instance on which the method is invoked.

Returns: A delegate of type bound to the specified instance.

Do
public static void Do(Action action, Action<Exception> error)
DelegateHelper.Do(action, error)

Executes the specified action and handles any exception using the provided error action.

action
The action to execute.
error
The action to handle exceptions.
GetInvocationList``1
public static IEnumerable<TDelegate> GetInvocationList<TDelegate>(TDelegate delegate)
result = DelegateHelper.GetInvocationList(delegate)

Returns an enumerable collection of delegates from the delegate's invocation list.

delegate
The delegate whose invocation list is retrieved.

Returns: An IEnumerable of representing the invocation list.

Invoke
public static void Invoke(PropertyChangedEventHandler handler, object sender, string name)
DelegateHelper.Invoke(handler, sender, name)

Invokes the PropertyChangingEventHandler with the specified sender and property name.

handler
The PropertyChangingEventHandler to invoke.
sender
The sender object.
name
The name of the property that changed.
Invoke
public static void Invoke(PropertyChangingEventHandler handler, object sender, string name)
DelegateHelper.Invoke(handler, sender, name)

Invokes the PropertyChangingEventHandler with the specified sender and property name.

handler
The PropertyChangingEventHandler to invoke.
sender
The sender object.
name
The name of the property that is changing.
RemoveDelegate``1
public static TDelegate RemoveDelegate<TDelegate>(TDelegate source, TDelegate value)
result = DelegateHelper.RemoveDelegate(source, value)

Removes the specified delegate from the source delegate.

source
The source delegate.
value
The delegate to remove from the source.

Returns: The resulting delegate of type after removal.