yyl
5 天以前 42cd1608acf5bb9f99ee16fa6db7d7e7fff072c6
Main/Utility/Extension.cs
@@ -1,4 +1,77 @@
class Extension
{
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;
            }
        }
    }
}