Exemple #1
0
        public static void Context(this ICoroutineRunner runner, Action action)
        {
            if (runner is null)
            {
                ThrowHelper.ArgNull(nameof(runner));
            }

            if (action is null)
            {
                ThrowHelper.ArgNull(nameof(action));
            }

            var prev = ICoroutineRunner.Instance;

            if (prev == runner)
            {
                action.Invoke();
            }
            else
            {
                ICoroutineRunner.Instance = runner;

                try
                {
                    action.Invoke();
                }
                finally
                {
                    ICoroutineRunner.Instance = prev;
                }
            }
        }
Exemple #2
0
        public static T Context <T>(this ICoroutineRunner runner, Func <T> init)
        {
            if (runner is null)
            {
                ThrowHelper.ArgNull(nameof(runner));
            }

            if (init is null)
            {
                ThrowHelper.ArgNull(nameof(init));
            }

            var prev = ICoroutineRunner.Instance;

            if (prev == runner)
            {
                return(init.Invoke());
            }
            else
            {
                ICoroutineRunner.Instance = runner;

                try
                {
                    return(init.Invoke());
                }
                finally
                {
                    ICoroutineRunner.Instance = prev;
                }
            }
        }
 public Composed(WaitingCoroutineRegisterNotifier[] notifiers)
 {
     if (notifiers is null)
     {
         ThrowHelper.ArgNull(nameof(notifiers));
     }
     _notifiers = notifiers;
 }