using System;
|
using System.Collections.Generic;
|
|
public static class Extension
|
{
|
public static void RemoveCompletely<T>(this System.Action<T> action, Action<T> removeAction)
|
{
|
if (null == action)
|
{
|
return;
|
}
|
|
Delegate[] invocations = action.GetInvocationList();
|
|
for (int i = 0; i < invocations.Length; i++)
|
{
|
if (invocations[i].Equals(removeAction))
|
{
|
action -= removeAction;
|
}
|
}
|
}
|
|
public static void RemoveCompletely<T, U>(this System.Action<T, U> action, Action<T, U> removeAction)
|
{
|
if (null == action)
|
{
|
return;
|
}
|
|
Delegate[] invocations = action.GetInvocationList();
|
|
for (int i = 0; i < invocations.Length; i++)
|
{
|
if (invocations[i].Equals(removeAction))
|
{
|
action -= removeAction;
|
}
|
}
|
}
|
|
public static void RemoveCompletely(this System.Action action, Action removeAction)
|
{
|
if (null == action)
|
{
|
return;
|
}
|
|
Delegate[] invocations = action.GetInvocationList();
|
|
for (int i = 0; i < invocations.Length; i++)
|
{
|
if (invocations[i].Equals(removeAction))
|
{
|
action -= removeAction;
|
}
|
}
|
}
|
|
public static void RemoveCompletely<T, U, V>(this System.Action<T, U, V> action, Action<T, U, V> removeAction)
|
{
|
if (null == action)
|
{
|
return;
|
}
|
|
Delegate[] invocations = action.GetInvocationList();
|
|
for (int i = 0; i < invocations.Length; i++)
|
{
|
if (invocations[i].Equals(removeAction))
|
{
|
action -= removeAction;
|
}
|
}
|
}
|
}
|