Class DelegateHelper
Provides helper methods for working with delegates.
public static class DelegateHelper
- Inheritance
-
DelegateHelper
- Inherited Members
Methods
AddDelegate<TDelegate>(TDelegate, TDelegate)
Combines two delegates of the same type.
public static TDelegate AddDelegate<TDelegate>(this TDelegate source, TDelegate value)
Parameters
source
TDelegateThe source delegate.
value
TDelegateThe delegate to combine with the source delegate.
Returns
- TDelegate
A combined delegate of type TDelegate.
Type Parameters
TDelegate
The type of the delegate.
CreateDelegate<TDelegate>(MethodInfo)
Creates a delegate of type TDelegate for the specified method.
public static TDelegate CreateDelegate<TDelegate>(this MethodInfo method)
Parameters
method
MethodInfoThe method information.
Returns
- TDelegate
A delegate of type TDelegate.
Type Parameters
TDelegate
The type of delegate to create.
CreateDelegate<TInstance, TDelegate>(MethodInfo, TInstance)
Creates a delegate of type TDelegate for the specified method and instance.
public static TDelegate CreateDelegate<TInstance, TDelegate>(this MethodInfo method, TInstance instance)
Parameters
method
MethodInfoThe method information.
instance
TInstanceThe instance on which the method is invoked.
Returns
- TDelegate
A delegate of type TDelegate bound to the specified instance.
Type Parameters
TInstance
The type of the instance.
TDelegate
The type of delegate to create.
Do(Action, Action<Exception>)
Executes the specified action and handles any exception using the provided error action.
public static void Do(this Action action, Action<Exception> error)
Parameters
Exceptions
- ArgumentNullException
Thrown when action or error is null.
DoAsync(Action, Action<Exception>)
Executes the specified action asynchronously and handles any exception using the provided error action.
public static void DoAsync(this Action action, Action<Exception> error)
Parameters
action
ActionThe action to execute asynchronously.
error
Action<Exception>The action to handle exceptions.
Exceptions
- ArgumentNullException
Thrown when action or error is null.
GetInvocationList<TDelegate>(TDelegate)
Returns an enumerable collection of delegates from the delegate's invocation list.
public static IEnumerable<TDelegate> GetInvocationList<TDelegate>(this TDelegate @delegate)
Parameters
delegate
TDelegateThe delegate whose invocation list is retrieved.
Returns
- IEnumerable<TDelegate>
An IEnumerable of TDelegate representing the invocation list.
Type Parameters
TDelegate
The type of the delegate.
Invoke(PropertyChangedEventHandler, object, string)
Invokes the PropertyChangedEventHandler with the specified sender and property name.
public static void Invoke(this PropertyChangedEventHandler handler, object sender, string name)
Parameters
handler
PropertyChangedEventHandlerThe PropertyChangedEventHandler to invoke.
sender
objectThe sender object.
name
stringThe name of the property that changed.
Invoke(PropertyChangingEventHandler, object, string)
Invokes the PropertyChangingEventHandler with the specified sender and property name.
public static void Invoke(this PropertyChangingEventHandler handler, object sender, string name)
Parameters
handler
PropertyChangingEventHandlerThe PropertyChangingEventHandler to invoke.
sender
objectThe sender object.
name
stringThe name of the property that is changing.
RemoveAllDelegates<TDelegate>(TDelegate)
Removes all invocation entries from the delegate.
public static void RemoveAllDelegates<TDelegate>(this TDelegate source)
Parameters
source
TDelegateThe delegate from which all delegates are removed.
Type Parameters
TDelegate
The type of the delegate.
RemoveDelegate<TDelegate>(TDelegate, TDelegate)
Removes the specified delegate from the source delegate.
public static TDelegate RemoveDelegate<TDelegate>(this TDelegate source, TDelegate value)
Parameters
source
TDelegateThe source delegate.
value
TDelegateThe delegate to remove from the source.
Returns
- TDelegate
The resulting delegate of type TDelegate after removal.
Type Parameters
TDelegate
The type of the delegate.