namespace System
{
    public static class ActionUtils
    {
        /// <summary>
        /// Action的安全回调
        /// </summary>
        /// <param name="action"></param>
        public static void SafeInvoke(this Action action)
        {
            try
            {
                action?.Invoke();
            }
            catch (Exception ex)
            {
                XGame.Log.Exception(ex);
            }
        }
        /// <summary>
        /// Action的安全回调
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="action"></param>
        /// <param name="obj"></param>
        public static void SafeInvoke<T>(this Action<T> action, T obj)
        {
            try
            {
                action?.Invoke(obj);
            }
            catch (Exception ex)
            {
                XGame.Log.Exception(ex);
            }
        }
    }
}
