예제 #1
0
파일: Static.cs 프로젝트: chakrit/fu-sharp
        public static Continuation Folder(this IStaticSteps _,
            string urlPrefix, string folder, Continuation on404)
        {
            on404 = on404 ?? fu.Http.NotFound();

              string folderPath = null;

              return step => ctx =>
              {
            var rawUrl = ctx.Request.Url.AbsolutePath;
            folderPath = folderPath ?? ctx.ResolvePath(folder);

            if (!rawUrl.StartsWith(urlPrefix)) {
              on404(step)(ctx);
              return;
            }

            var url = rawUrl.Substring(urlPrefix.Length);
            var filePath = Path.Combine(folderPath, url);

            if (!System.IO.File.Exists(filePath)) {
              on404(step)(ctx);
              return;
            }

            step(FileResult.From(ctx, filePath));
              };
        }
예제 #2
0
 public static Continuation If(Reduce<bool> predicate,
     Continuation trueCont, Continuation falseCont)
 {
     return step => ctx =>
       {
     if (predicate(ctx))
       trueCont(step)(ctx);
     else
       falseCont(step)(ctx);
       };
 }
예제 #3
0
        private static Continuation redirectStep(Continuation header, Filter<string> urlFilter)
        {
            return step => outerCtx =>
              {
            header(ctx =>
            {
              var targetUrl = urlFilter(ctx, ctx.Request.Url.AbsolutePath);
              ctx.Response.Redirect(targetUrl);
            })(outerCtx);

            // step is discarded
            // (we're redirecting, so no more processing should take place)
              };
        }
		public void ContinuationChaining()
		{
			var o1 = new Order(false, false);
			var o2 = new Order(true, false);
			var o3 = new Order(true, true);

			var v = new OrderValidator();
			var r = new OrderRepo();
			var c = new OrderConfirmationSender();

			var validate = new Continuation<Order>(order => order.When(o => v.Validate(o)));
			var save = new Continuation<Order>(order => order.When(o => r.Save(o)));
			var send = new Continuation<Order>(order => order.Do(o => c.Send(o)));
			
			var proc = new Continuation<Order>(
				order => order.When(validate).When(save).Do(send));

			proc.Execute(o1);
			proc.Execute(o2);
			proc.Execute(o3);

			Assert.That(c.SentConfirmations.Contains(o1), Is.False);
			Assert.That(c.SentConfirmations.Contains(o2), Is.False);
			Assert.That(c.SentConfirmations.Contains(o3), Is.True);
		}
예제 #5
0
        static void Main()
        {
            //			DateTime time1 = DateTime.Now;
            int a3 = 0x3beef;
            int a2 = 0x2beef;
            int a1 = 0x1beef;

            Continuation c = new Continuation();

            int v1 = 111;
            int v2 = 222;

            tt(v1, v2, c, 1);

            a1++;
            a2++;
            a3++;

            tt(v1, v2, c, 2);

            //			DateTime time2 = DateTime.Now;

            Console.WriteLine("{0:x}, {1:x}, {2:x}", a1, a2, a3);
            //			Console.WriteLine("total {0}", res);
            //			Console.WriteLine("time {0}ms", (time2 - time1).Milliseconds);
            //			Console.WriteLine("END");
        }
예제 #6
0
 public Continuation(Continuation cont, LexicalEnvironment envt, object evalStack, Template template, uint pc)
 {
     CONT = cont;
     ENVT = envt;
     EVAL_STACK = evalStack;
     TEMPLATE = template;
     PC = pc;
 }
예제 #7
0
        protected override void Map(string url,
            Func<Continuation, Continuation, Continuation> wrapper,
            Continuation handler)
        {
            handler = handler.Then(fu.Result.Render(EnableHttpCompression));

              base.Map(url, wrapper, handler);
        }
예제 #8
0
파일: Map.cs 프로젝트: chakrit/fu-sharp
        public static Continuation Custom(this IMapSteps _,
            ContDict mappings, Reduce<string> pathReducer, Continuation on404)
        {
            var dict = mappings.ToDictionary(
            kv => new Regex(kv.Key),
            kv => kv.Value);

              return _.Custom(dict, pathReducer, on404);
        }
예제 #9
0
파일: Map.cs 프로젝트: chakrit/fu-sharp
        public static Continuation Hosts(this IMapSteps _,
            ContDict mappings, Continuation on404)
        {
            var dict = mappings.ToDictionary(
            kv => new Regex(kv.Key),
            kv => kv.Value);

              return _.Hosts(dict, on404);
        }
예제 #10
0
        static int tt1(Continuation c, int val)
        {
            Console.WriteLine("before store, {0}", val);
            int ret = c.Store(0);
            Console.WriteLine("after store, {0}", val);

            Console.WriteLine("loop {0}", ret);

            return ret;
        }
예제 #11
0
파일: Map.cs 프로젝트: chakrit/fu-sharp
        public static Continuation Custom(this IMapSteps _,
            ContRegexDict mappings,
            Reduce<string> pathReducer, Continuation on404)
        {
            on404 = on404 ?? fu.Http.NotFound();

              return step => ctx =>
              {
            var path = pathReducer(ctx);
            var result = mappings
              .Select(kv => new { Match = kv.Key.Match(path), Cont = kv.Value })
              .FirstOrDefault(m => m.Match.Success);

            if (result == null)
              on404(step)(ctx);
            else
              result.Cont(step)(new UrlMappedContext(ctx, result.Match));
              };
        }
예제 #12
0
        public static FSContinuation ToFSharp(Continuation cont)
        {
            return FuncConvert.ToFSharpFunc<FSAction, FSAction>(next =>
              {
            var nextAct = fu.FromFSharp(next);
            nextAct = cont(nextAct);

            return fu.ToFSharp(nextAct);
              });
        }
예제 #13
0
        public override Continuation Evaluate(Continuation c, Environment env, Datum args)
        {
            var argList = args.ToArray();

            if (argList.Length != 2)
            {
                throw c.error("Expected 2 arguments: (define <symbol> <expression>). Got {0} instead", argList.Length);
            }
            var name       = argList[0].CastIdentifier();
            var expression = argList[1];

            c = c.PushTask(new DefineName(env, name));
            return(c.Evaluate(env, expression));
        }
        public void ReturnsTrueIfAllContinuationsInGroupAreCompleted()
        {
            var continuation = new Continuation
            {
                Status   = JobStatus.Created,
                Children = new[] { new Continuation {
                                       Status = JobStatus.Completed
                                   } }
            };

            var result = continuation.CanContinue();

            Assert.True(result);
        }
        public void ReturnsFalseIfAnyChildContinuationIsNotContinuable()
        {
            var continuation = new Continuation
            {
                Status   = JobStatus.Created,
                Children = new[] { new Continuation {
                                       Status = JobStatus.Poisoned
                                   } }
            };

            var result = continuation.CanContinue();

            Assert.False(result);
        }
        public void ShouldNotReturnNextIfAllChilrenAreNotComplete()
        {
            var continuation = new Continuation
            {
                Children = new[]
                {
                    new Continuation()
                },
                Next = new Continuation()
            };

            var pending = continuation.PendingContinuations();

            Assert.DoesNotContain(continuation.Next, pending);
        }
        public void ReturnsNextIfAllContinuationsInGroupedIsComplete()
        {
            var continuation = new Continuation
            {
                Type     = ContinuationType.Parallel,
                Children = new[] { new Continuation {
                                       Status = JobStatus.Completed
                                   } },
                Next = new Continuation()
            };

            var pending = continuation.PendingContinuations();

            Assert.Equal(continuation.Next, pending.Single());
        }
예제 #18
0
            public override Continuation Evaluate(Continuation oldContinuation, Datum args)
            {
                // Replace the old continuation with the new continuation - but pass in the
                // supplied argument as the 'return value' of the new continuation.
                var argArray = args.ToArray();

                // We allow calling a "continuation" with 0 args. Such a continuation
                // only arises from the error function.
                // TODO: we should differentiate the two with an "expected args" member which we can error check.
                if (argArray.Length == 0)
                {
                    return(c);
                }
                return(c.PushResult(argArray[0]));
            }
예제 #19
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            var idx = info.ButtonID - 1;

            if (idx >= 0 && idx < m_Entries.Length)
            {
                BodyId = m_Entries[idx].BodyId;
            }

            IsCompleted = true;
            Continuation?.Invoke();

            // Spell spell = new PolymorphSpell(m_Caster, m_Scroll, m_Entries[idx].BodyId);
            // spell.Cast();
        }
예제 #20
0
            public Continuation Perform(Continuation c)
            {
                // The result datum may be a graph. This makes certain
                // optimizations risky.
                var expansion = c.Result;

                if (macroDatum != null)
                {
                    // Cache macro expansions. In the extremely
                    // common case of the same macro being used on the
                    // same Datum, re-use the expansion.
                    macroDatum.Cache = cons(macro, expansion);
                }
                return(c.PopResult().PopEnv().Evaluate(c.Env, expansion));
            }
예제 #21
0
        public void Run(bool Automatic)
        {
            AutomaticVerify = Automatic;

            Continuation Continuation = new Continuation();

            if (Automatic && Project.LastVerifyRelativePath != null && Project.LastVerifyRelativePath.Length > 0)
            {
                Continuation.Starting         = true;
                Continuation.LastRelativePath = Project.LastVerifyRelativePath;
                Continuation.StartPass();
            }

            Run(ref Continuation);
        }
예제 #22
0
        public Continuation Calculate(SuperInputCalcViewModel input)
        {
            var     continuation     = new Continuation();
            var     model            = new OverseedBagsNeededCalcViewModel();
            var     field            = _repository.Find <Field>(Int64.Parse(input.Field));
            var     inventoryProduct = _repository.Find <InventoryProduct>(Int64.Parse(input.Product));
            decimal bagSizeInPounds  = _unitSizeTimesQuantyCalculator.CalculateLbsPerUnit(inventoryProduct);
            double? bagsNeeded       = ((input.SeedRate / (input.OverSeedPercent * .01)) * (Convert.ToDouble(field.Size / 1000))) / Convert.ToDouble(bagSizeInPounds);

            model.BagsNeeded    = Convert.ToDouble(Math.Round(Convert.ToDecimal(bagsNeeded), 2));
            model.BagSize       = inventoryProduct.SizeOfUnit + " " + inventoryProduct.UnitType;
            model.FieldArea     = field.Size.ToString();
            continuation.Target = model;
            return(continuation);
        }
예제 #23
0
        public void ContinuationWithOptionSuccess()
        {
            Continuation <object, int> continuation = 10;

            Option <string> optionResult =
                continuation
                .Then(value => value % 2 == 0)
                .Then(value => value ? "Even" : "Odd");

            string result = optionResult.Match(
                value => value,
                () => string.Empty);

            Assert.AreEqual(result, "Even");
        }
        public void ReturnsFalseIfAnyFailureHandlerIsFailed()
        {
            var continuation = new Continuation
            {
                Status = JobStatus.Poisoned,
                ContinueAfterHandlingFailure = true,
                OnAllFailed = new Continuation {
                    Status = JobStatus.Poisoned
                }
            };

            var result = continuation.CanContinue();

            Assert.False(result);
        }
예제 #25
0
파일: Job.cs 프로젝트: Matty666/Molecules
        public Job(
            Guid id,
            Type type,
            string method,
            object[] arguments,
            DateTime createdOn,
            Guid?rootId        = null,
            Guid?parentId      = null,
            Guid?correlationId = null,
            JobStatus status   = JobStatus.Ready,
            int dispatchCount  = 0,
            DateTime?retryOn   = null,
            ExceptionFilter[] exceptionFilters = null,
            Continuation continuation          = null,
            bool?suspended = null)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            if (arguments == null)
            {
                throw new ArgumentNullException("arguments");
            }
            if (string.IsNullOrWhiteSpace(method))
            {
                throw new ArgumentException("A valid method is required.");
            }

            Method    = method;
            Id        = id;
            Type      = type;
            Arguments = arguments;
            CreatedOn = createdOn;

            RootId        = rootId ?? id;
            ParentId      = parentId;
            CorrelationId = correlationId ?? id;
            Status        = status;
            DispatchCount = dispatchCount;
            RetryOn       = retryOn;

            Properties = new Dictionary <string, object>();

            ExceptionFilters = exceptionFilters ?? new ExceptionFilter[0];
            Continuation     = continuation;
            Suspended        = suspended ?? false;
        }
예제 #26
0
    static void Main()
    {
        Continuation c = new Continuation();

        c.Mark();

        int foo = 123;
        int val = c.Store(0);

        Console.WriteLine("{0} {1}", val, foo);

        foo = 321;

        if (val < 5)
            c.Restore(val + 1);
    }
예제 #27
0
        public void ContinuationWithMultiplesThen()
        {
            Continuation <string, int> continuation = 1;

            Option <int> optionResult =
                continuation
                .Then(value => value + 4)
                .Then(value => value + 10);


            int result = optionResult.Match(
                value => value,
                () => 0);

            Assert.AreEqual(result, 15);
        }
예제 #28
0
        public void Should_property_manage_the_async_bits()
        {
            string path = Assembly.GetExecutingAssembly().Location;

            var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, true);

            Continuation <string> continuation = fileStream.AsyncReadToEnd(x => { });

            var result = new Future <string>();

            continuation(result.Complete);

            result.WaitUntilCompleted(10.Seconds()).ShouldBeTrue();

            Trace.WriteLine(result.Value.Length);
        }
예제 #29
0
 internal void Run()
 {
     State = MicroThreadState.Running;
     if (Continuation == null)
     {
         Continuation = new Continuation();
         Continuation.Mark();
         cb();
         State = MicroThreadState.Done;
         Loop.GetMicroThreadCollection().Next();
     }
     else
     {
         Continuation.Restore(1);
     }
 }
예제 #30
0
        public override Continuation Evaluate(Continuation c, Datum args)
        {
            var datumArgs = args.ToArray();

            if (datumArgs.Length != 2)
            {
                throw c.error("Apply expects 2 arguments. {0} passed", datumArgs.Length);
            }
            var function = datumArgs[0] as StackFunction;

            if (function == null)
            {
                throw c.error("'{0}' is not a function", datumArgs[0]);
            }
            return(function.Evaluate(c, datumArgs[1]));
        }
예제 #31
0
        public void Yielding()
        {
            Continuation baseCont = new Continuation();
            Continuation taskCont = new Continuation();

            baseCont.Mark();
            taskCont.Mark();

            // Store the base continuation to start the task
            if (baseCont.Store(0) == 0)
            {
                bool done  = false;
                int  count = 0;

                while (!done)
                {
                    // Do stuff for the task.
                    ++count;

                    // This task is counting to 100.
                    if (count == 100)
                    {
                        done = true;
                    }

                    // Yield every 10 loops
                    else if (count % 10 == 0)
                    {
                        // To yield, store the task continuation then restore
                        // the base continuation.
                        if (taskCont.Store(0) == 0)
                        {
                            baseCont.Restore(1);
                        }
                    }
                }
            }
            // When restored, 'Store' will return what was passed to Restore, in this case 1 so fall here.
            else
            {
                // Count the yields, then go back to the task.
                ++yields;
                taskCont.Restore(1);
            }

            Assert.AreEqual(9, yields);
        }
예제 #32
0
        public override bool Try(TextBuffer output, BindingEnvironment e, Continuation k, MethodCallFrame predecessor)
        {
            var s         = e.State;
            var callCount = e.Frame.Task.CallCount(s);
            var readyTime = ReadyTime(s);

            if (callCount > readyTime)
            {
                var newState = ReadyTimes.SetItem(s, this, Duration == int.MaxValue ? int.MaxValue : (callCount + Duration));
                if (Continue(output, new BindingEnvironment(e, e.Unifications, newState), k, predecessor))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #33
0
        public override Continuation Evaluate(Continuation c, Datum args)
        {
            var argArray = args.ToArray();

            if (argArray.Length != 1)
            {
                throw DatumHelpers.error("call/cc: expect a single function as an argument. Got {0}", argArray.Length);
            }
            var arg      = argArray[0];
            var function = arg as StackFunction;

            if (function == null)
            {
                throw DatumHelpers.error("call/cc: {0} must be a function", arg);
            }
            return(function.Evaluate(c, DatumHelpers.compound(new ContinuationFunction(c))));
        }
예제 #34
0
        public void ContinuationWithMultiplesThenOperator()
        {
            Continuation <string, int> continuation = 1;

            Option <int> optionResult =
                continuation
                > (value => value + 4)
                > (value => value + 10)
                > (value => value * 2);


            int result = optionResult.Match(
                value => value,
                () => 0);

            Assert.AreEqual(result, 30);
        }
예제 #35
0
        public override Continuation Evaluate(Continuation c, LexicalEnvironment env, Datum args)
        {
            var argList = args.ToArray();

            if (argList.Length != 2)
            {
                throw c.error("Expected 2 arguments: (define <symbol> <expression>). Got {0} instead", argList.Length);
            }
            var name       = argList[0].CastSymbol();
            var expression = argList[1];

            c = c.PushTask(
                tc => { env.Define(name, tc.Result);
                        return(tc); },
                "define '{0}'", name);
            return(c.Evaluate(env, expression));
        }
예제 #36
0
        public void ContinuationWithMultiplesParametersThen()
        {
            int extraInput = 5;
            Continuation <string, int> continuation = 1;

            Option <int> optionResult =
                continuation
                .Then(value => value + 4)
                .Then <int, int>((input, value) => input + value + 10, extraInput);


            int result = optionResult.Match(
                value => value,
                () => 0);

            Assert.AreEqual(result, 20);
        }
예제 #37
0
        protected Continuation RhoTranslate(string rhoScript, bool trace = false, EStructure st = EStructure.Program)
        {
            var trans = new RhoTranslator(_Registry);

            if (!trans.Translate(rhoScript, out var cont, st))
            {
                WriteLine($"Error: {trans.Error}");
            }

            if (trace)
            {
                WriteLine(trans.ToString());
            }

            Assert.IsFalse(trans.Failed, trans.Error);
            return(_Continuation = cont);
        }
예제 #38
0
    static void Main()
    {
        Continuation c = new Continuation();

        c.Mark();

        int foo = 123;
        int val = c.Store(0);

        Console.WriteLine("{0} {1}", val, foo);

        foo = 321;

        if (val < 5)
        {
            c.Restore(val + 1);
        }
    }
        public void ShouldReturnAllFailedContinuationIfAllContinuationsInGroupedIsFailed()
        {
            var continuation = new Continuation
            {
                Type     = ContinuationType.Parallel,
                Children = new[]
                {
                    new Continuation {
                        Status = JobStatus.Poisoned
                    }
                },
                OnAllFailed = new Continuation()
            };

            var pending = continuation.PendingContinuations();

            Assert.Equal(continuation.OnAllFailed, pending.Single());
        }
        public void ReturnsTrueIfAllFailureHandlersAreCompleted()
        {
            var continuation = new Continuation
            {
                Status = JobStatus.Poisoned,
                ContinueAfterHandlingFailure = true,
                OnAnyFailed = new Continuation {
                    Status = JobStatus.Completed
                },
                OnAllFailed = new Continuation {
                    Status = JobStatus.Completed
                }
            };

            var result = continuation.CanContinue();

            Assert.True(result);
        }
예제 #41
0
        public override bool Try(TextBuffer output, BindingEnvironment e, Continuation k, MethodCallFrame predecessor)
        {
            var collectionValue = e.Resolve(collectionVariable);

            switch (collectionValue)
            {
            case Cons list:
            {
                return(list != Cons.Empty &&
                       e.Unify(element, list.First, out var bindings) &&
                       Continue(output,
                                new BindingEnvironment(e,
                                                       bindings,
                                                       e.State.Bind(collectionVariable, list.Rest)),
                                k, predecessor));
            }

            case ImmutableStack <object> stack:
            {
                return(!stack.IsEmpty &&
                       e.Unify(element, stack.Peek(), out var bindings) &&
                       Continue(output,
                                new BindingEnvironment(e,
                                                       bindings,
                                                       e.State.Bind(collectionVariable, stack.Pop())),
                                k, predecessor));
            }

            case ImmutableQueue <object> queue:
            {
                return(!queue.IsEmpty &&
                       e.Unify(element, queue.Peek(), out var bindings) &&
                       Continue(output,
                                new BindingEnvironment(e,
                                                       bindings,
                                                       e.State.Bind(collectionVariable, queue.Dequeue())),
                                k, predecessor));
            }

            default:
                throw new ArgumentTypeException("removeNext", typeof(Cons), collectionValue,
                                                new[] { "removeNext", collectionValue });
            }
        }
예제 #42
0
        public async Task RemoveRangeAsync(IEnumerable <TResult> dtos, NotFound <TResult, int> notFound = null,
                                           CancellationToken cancellationToken = default(CancellationToken))
        {
            if (dtos == null)
            {
                throw new ArgumentNullException(nameof(dtos));
            }
            var dtoArray     = dtos.ToArray();
            var entities     = new List <T>(dtoArray.Length);
            var hasError     = false;
            var continuation = new Continuation();

            for (var index = 0; index < dtoArray.Length; index++)
            {
                var dto    = dtoArray[index];
                var entity = await _dbSet.FindAsync(GetKeyValues(dto), cancellationToken);

                if (entity == null)
                {
                    (notFound ?? NotFound).Invoke(dto, index, continuation);
                    hasError = true;
                    if (continuation.Yes)
                    {
                        continue;
                    }
                    break;
                }

                entities.Add(entity);
            }

            if (hasError)
            {
                return;
            }
            if (SoftDelete)
            {
                _rules.Apply(entities, DataAction.Remove);
            }
            else
            {
                _dbSet.RemoveRange(entities);
            }
        }
예제 #43
0
        // this is expensive, but only called when continuation is invoked
        static bool CheckStack(Continuation cc)
        {
            if (!DoCheckStack)
            {
                return(true);
            }

            var st = new StackTrace();
            var c1 = cc.Stack.GetFrames();
            var f1 = st.GetFrames();

            if (cc.Thread != Thread.CurrentThread)
            {
                // can't check reliably
                return(true);
            }

            if (IsMono)
            {
                // mono: for some reason the one stack is reversed... but not all the time... FFFFFUUUUUU!! 8/
                if (c1[0].GetMethod().Name != "Main")
                {
                    Array.Reverse(c1);
                }
                if (f1[0].GetMethod().Name != "Main")
                {
                    Array.Reverse(f1);
                }
            }
            else
            {
                Array.Reverse(c1);
                Array.Reverse(f1);
            }

            for (int i = 0; i < c1.Length; i++)
            {
                if (c1[i].GetMethod() != f1[i].GetMethod())
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #44
0
 public long GetNext()
 {
     if (m_cont == null)
     {
         m_cont = new Continuation();
         m_cont.Mark();
         for (long i = m_min; i < m_max; i++)
         {
             if (m_cont.Store(0) == 0)
                 return i;
         }
         return 0;
     }
     else
     {
         m_cont.Restore(1);
         throw new Exception("not reached");
     }
 }
예제 #45
0
        static void tt(int v1, int v2, Continuation c, int state)
        {
            if(state == 1)
            {
                c.Mark();

                int val = tt1(c, 0);

                Console.WriteLine(v1);
                Console.WriteLine(v2);

                v1++;
                v2++;
            }
            else
            {
                tt2(c, 1);
            }
        }
예제 #46
0
 public static Continuation Methods(this IMapSteps _,
     Continuation get, Continuation put, Continuation post, Continuation delete,
     Continuation on405)
 {
     var orDelete = _.Delete(delete, on405);
       var orPut = _.Put(put, orDelete);
       var orPost = _.Post(post, orPut);
       return _.Get(get, orPost);
 }
예제 #47
0
 public static Continuation GetHead(this IMapSteps _,
     Continuation getAndHead)
 {
     return _.GetHead(getAndHead, null);
 }
예제 #48
0
 public void OnCompleted(Action action)
 {
     Continuation newContinuation = new Continuation(action);
     Continuation oldContinuation;
     if (!coordinator.labels.TryGetValue(label, out oldContinuation))
     {
         // First time coming from this label. Always succeeds.
         coordinator.labels[label] = newContinuation;
     }
     else
     {
         // Current semantics are to prohibit two different ComeFrom calls for the same label.
         // An alternative would be to just replace the existing continuation with the new one,
         // in which case we wouldn't need any of this - we could just use
         // coordinator.labels[label] = newContinuation;
         // unconditionally.
         if (!oldContinuation.Equals(newContinuation))
         {
             throw new InvalidOperationException("Additional continuation detected for label " + label);
         }
         // Okay, we've seen this one before. Nothing to see here, move on.
     }
     // We actually want to continue from where we were: we're only really marking the
     // ComeFrom point.
     coordinator.stack.Push(action);
 }
예제 #49
0
 public static Continuation Post(this IMapSteps _,
     Continuation post, Continuation on405)
 {
     return _.Method("POST", post, on405);
 }
예제 #50
0
 private void Push(Continuation continuation)
 {
     Debug.Assert(continuation != null);
     
     if (_stack == null)
         _stack = new Stack(6);
     
     _stack.Push(continuation);
 }
예제 #51
0
 internal LabelAwaiter(Continuation continuation, Coordinator coordinator)
 {
     this.continuation = continuation;
     this.coordinator = coordinator;
 }
예제 #52
0
 public static Continuation Head(this IMapSteps _,
     Continuation head, Continuation on405)
 {
     return _.Method("HEAD", head, on405);
 }
예제 #53
0
        public static Continuation Method(this IMapSteps _, string method,
            Continuation onMethod, Continuation on405)
        {
            on405 = on405 ?? fu.Http.MethodNotAllowed();
              method = method.ToUpper();

              return step => ctx =>
            (ctx.Request.HttpMethod == method ? onMethod : on405)(step)(ctx);
        }
예제 #54
0
 public static Continuation GetPost(this IMapSteps _,
     Continuation get, Continuation post, Continuation on405)
 {
     var orPost = _.Post(post, on405);
       return _.Get(get, orPost);
 }
예제 #55
0
 public static Continuation GetPost(this IMapSteps _,
     Continuation get, Continuation post)
 {
     return _.GetPost(get, post, null);
 }
예제 #56
0
 public static Continuation Delete(this IMapSteps _,
     Continuation delete, Continuation on405)
 {
     return _.Method("DELETE", delete, on405);
 }
예제 #57
0
        /// <summary> 
        /// Yields control back to the reader's user while updating the
        /// reader with the new found token, its text and the next 
        /// continuation point into the reader.
        /// </summary>
        /// <remarks>
        /// By itself, this method cannot affect the stack such tha control 
        /// is returned back to the reader's user. This must be done by 
        /// Yield's caller by way of explicit return.
        /// </remarks>

        private JsonToken Yield(JsonToken token, Continuation continuation)
        {
            if (continuation != null)
                _stack.Push(continuation);
            
            return token;
        }
예제 #58
0
 public static Continuation Get(this IMapSteps _,
     Continuation get, Continuation on405)
 {
     return _.Method("GET", get, on405);
 }
예제 #59
0
 public static Continuation Put(this IMapSteps _,
     Continuation put, Continuation on405)
 {
     return _.Method("PUT", put, on405);
 }
예제 #60
0
 public static Continuation GetHead(this IMapSteps _,
     Continuation getAndHead, Continuation on405)
 {
     var orHead = _.Head(getAndHead, on405);
       return _.Get(getAndHead, orHead);
 }