// ************************** 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)); } }
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); } }
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)); }
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); }
static Bounce <Exception> ExceptionDelver(Exception currentException) { Exception?innerException = currentException.InnerException; return(innerException == null?Bounce.Finish(currentException) : Bounce.Continue(innerException)); }
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)); }