ArgNull() public static méthode

public static ArgNull ( string paramName ) : void
paramName string
Résultat void
        internal void AddOnCanceled(Action onCanceled)
        {
            if (onCanceled is null)
            {
                ThrowHelper.ArgNull(nameof(onCanceled));
            }

            if (IsCompleted)
            {
                ThrowHelper.InvalidOp("Coroutine is already completed");
            }

            if (IsCanceled)
            {
                onCanceled.Invoke();
                return;
            }

            var runner = ICoroutineRunner.GetContext();

            if (Runner == runner)
            {
                OnCalceled += onCanceled;
            }
            else
            {
                OnCalceled += () => runner.Context(onCanceled);
            }
        }
Exemple #2
0
        public static T OnUpdating <T>(this T coroutine, Action onUpdating)
            where T : AwaitableCoroutineBase
        {
            if (coroutine is null)
            {
                ThrowHelper.ArgNull(nameof(coroutine));
            }

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

            if (coroutine.IsCanceled)
            {
                ThrowHelper.InvalidOp("Coroutine is already canceled");
            }

            if (coroutine.IsCompleted)
            {
                ThrowHelper.InvalidOp("Coroutine is already completed");
            }

            coroutine.OnUpdating += onUpdating;
            return(coroutine);
        }
        internal void ContinueWith(Action action)
        {
            if (action is null)
            {
                ThrowHelper.ArgNull(nameof(action));
            }

            if (IsCanceled)
            {
                ThrowHelper.InvalidOp("Coroutine is already canceled");
            }

            if (IsCompleted)
            {
                action.Invoke();
                return;
            }

            var runner = ICoroutineRunner.GetContext();

            if (Runner == runner)
            {
                OnCompleted += action;
            }
            else
            {
                OnCompleted += () => runner.Context(action);
            }
        }
Exemple #4
0
        public static async AwaitableCoroutine AndThen(this AwaitableCoroutine coroutine, Func <AwaitableCoroutine> thunk)
        {
            if (thunk is null)
            {
                ThrowHelper.ArgNull(nameof(thunk));
            }

            await coroutine;

            await thunk();
        }
Exemple #5
0
        public static async AwaitableCoroutine <U> AndThen <T, U>(this AwaitableCoroutine <T> coroutine, Func <T, AwaitableCoroutine <U> > thunk)
        {
            if (thunk is null)
            {
                ThrowHelper.ArgNull(nameof(thunk));
            }

            var res = await coroutine;

            return(await thunk(res));
        }
Exemple #6
0
        public static async AwaitableCoroutine <T> AndThen <T>(this AwaitableCoroutine coroutine, Func <AwaitableCoroutine <T> > thunk)
        {
            if (thunk is null)
            {
                ThrowHelper.ArgNull(nameof(thunk));
            }

            await coroutine;

            return(await thunk());
        }
Exemple #7
0
        public static async AwaitableCoroutine FromEnumerator(IEnumerator enumerator)
        {
            if (enumerator is null)
            {
                ThrowHelper.ArgNull(nameof(enumerator));
            }

            while (enumerator.MoveNext())
            {
                await Yield();
            }
        }
        public static async AwaitableCoroutine While(Func <bool> predicate)
        {
            if (predicate is null)
            {
                ThrowHelper.ArgNull(nameof(predicate));
            }

            while (predicate())
            {
                await Yield();
            }
        }
Exemple #9
0
        public static T OnCompleted <T>(this T coroutine, Action onCompleted)
            where T : AwaitableCoroutineBase
        {
            if (coroutine is null)
            {
                ThrowHelper.ArgNull(nameof(coroutine));
            }

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

            coroutine.ContinueWith(onCompleted);
            return(coroutine);
        }
Exemple #10
0
        public static T OnCanceled <T>(this T coroutine, Action onCanceled)
            where T : AwaitableCoroutineBase
        {
            if (coroutine is null)
            {
                ThrowHelper.ArgNull(nameof(coroutine));
            }

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

            coroutine.AddOnCanceled(onCanceled);
            return(coroutine);
        }
        public static async AwaitableCoroutine UntilCompleted <T>(this AwaitableCoroutineBase coroutine, Func <AwaitableCoroutine <T> > action)
        {
            if (coroutine is null)
            {
                ThrowHelper.ArgNull(nameof(coroutine));
            }

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

            while (!coroutine.IsCompleted)
            {
                if (coroutine.IsCanceled)
                {
                    AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(coroutine);
                }
                _ = await action.Invoke();
            }
        }
        public static async AwaitableCoroutine UntilCompleted(this AwaitableCoroutineBase coroutine, Func <AwaitableCoroutine> createCoroutine)
        {
            if (coroutine is null)
            {
                ThrowHelper.ArgNull(nameof(coroutine));
            }

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

            while (!coroutine.IsCompleted)
            {
                if (coroutine.IsCanceled)
                {
                    AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(coroutine);
                }
                await createCoroutine.Invoke();
            }
        }
Exemple #13
0
        public static async AwaitableCoroutine <U> Select <T, U>(this AwaitableCoroutine <T> coroutine, Func <T, U> thunk)
        {
            if (coroutine is null)
            {
                ThrowHelper.ArgNull(nameof(coroutine));
            }

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

            while (!coroutine.IsCompleted)
            {
                if (coroutine.IsCanceled)
                {
                    AwaitableCoroutine.ThrowChildCancel <AwaitableCoroutineBase>(coroutine);
                }
                await AwaitableCoroutine.Yield();
            }

            return(thunk(coroutine.Result));
        }