Exemplo n.º 1
0
        // ************************** QUEUE CALLBACKS - called from Trampoline/bounce ******************************************************************************


        // -----------------------------------------------------------------------------------
        static Bounce ProcessQueue(Queue <GameEvent> q, DelegateSet delegateSet)
        // -----------------------------------------------------------------------------------
        {
            if (q.Count == 0)
            {
                return(Bounce.End());
            }
            else
            {
                ProcessEvent(q.Peek(), delegateSet);
                q.Dequeue();
                return(Bounce.Continue(q));
            }
        }
Exemplo n.º 2
0
            public static void Start(Func <Queue <GameEvent>, DelegateSet, Bounce> action, DelegateSet delegateSet)

            {
                Bounce bounce = Bounce.Continue(delegateSet.Queue);

                while (true)
                {
                    if (bounce.HasResult)
                    {
                        break;
                    }

                    bounce = action(bounce.Queue, delegateSet);
                }
            }
Exemplo n.º 3
0
        private Bounce <List <string>, Stack <string>, List <string> > Iteration(List <string> files, Stack <string> directoriesToScan)
        {
            var rootDirectory  = directoriesToScan.Pop();
            var subdirectories = Directory.EnumerateDirectories(rootDirectory);

            foreach (var subdirectory in subdirectories)
            {
                directoriesToScan.Push(subdirectory);
            }

            files.AddRange(GetFilesFromDirectory(rootDirectory));

            return(directoriesToScan.Count == 0 ? Bounce <List <string>, Stack <string>, List <string> > .End(files) :
                   Bounce <List <string>, Stack <string>, List <string> > .Continue(files, directoriesToScan));
        }
Exemplo n.º 4
0
        public static TResult Start <T1, T2, TResult>(Func <T1, T2, Bounce <T1, T2, TResult> > action,
                                                      T1 arg1, T2 arg2)
        {
            TResult result = default(TResult);
            Bounce <T1, T2, TResult> bounce = Bounce <T1, T2, TResult> .Continue(arg1, arg2);

            while (true)
            {
                if (bounce.HasResult)
                {
                    result = bounce.Result;
                    break;
                }

                bounce = action(bounce.Arg1, bounce.Arg2);
            }

            return(result);
        }
Exemplo n.º 5
0
            static Bounce <Exception> ExceptionDelver(Exception currentException)
            {
                Exception?innerException = currentException.InnerException;

                return(innerException == null?Bounce.Finish(currentException) : Bounce.Continue(innerException));
            }
Exemplo n.º 6
0
 private Bounce <int, int, int> Iteration(int currentValue, int n)
 {
     return(n == 0 ? Bounce <int, int, int> .End(currentValue) :
            Bounce <int, int, int> .Continue(currentValue *n, n - 1));
 }