using System;
namespace TyphoonUI
{
///
/// 二次封装回调,支持中断
///
public class ActionHandler
{
public Action Handler;
public bool AutoRelease { get; set; }
public ActionHandler(Action handler, bool autoRelease = true)
{
Handler = handler;
AutoRelease = autoRelease;
}
public void Invoke()
{
Handler?.Invoke();
if (AutoRelease)
{
Handler = null;
}
}
public void Clear()
{
Handler = null;
}
}
///
/// 二次封装回调,支持中断
///
public class ActionHandler
{
public Action Handler;
public bool AutoRelease { get; set; }
public ActionHandler(Action handler, bool autoRelease = true)
{
Handler = handler;
AutoRelease = autoRelease;
}
public void Invoke(T t)
{
Handler?.Invoke(t);
if (AutoRelease)
{
Handler = null;
}
}
public void Clear()
{
Handler = null;
}
}
}