DelegateHelper
Provides helper methods for working with delegates.
Methods
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 .
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 .
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.
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.
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.
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.
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.
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.