コード例 #1
0
        public TestFalcorRouter()
        {
            Get["foo[{integers:ids}].name"] = parameters =>
            {
                NumericSet ids     = parameters.ids;
                var        results = ids.Select(id => new PathValue(FalcorPath.Create("foo", id, "name"), "Jill-" + id));
                return(CompleteAsync(results));
            };

            Get["foo"] = parameters => CompleteAsync(new PathValue(FalcorPath.Create("foo"), "bar"));

            Set["todos[{integers:ids}].done"] = async parameters =>
            {
                try
                {
                    NumericSet ids       = parameters.ids;
                    dynamic    jsonGraph = parameters.jsonGraph;

                    ids.ToList().ForEach(id =>
                    {
                        todos[id].done = (bool)jsonGraph["todos"][id.ToString()]["done"];
                    });

                    var result = await Task.FromResult(ids.Select(id => Path("todos", id).Key("done").Atom(todos[id].done)));

                    return(Complete(result));
                }
                catch (Exception)
                {
                    return(null);
                }
            };
        }
コード例 #2
0
        public TestFalcorRouter()
        {
            Get["foo[{integers:ids}].name"] = parameters =>
            {
                NumericSet ids     = parameters.ids;
                var        results = ids.Select(id => new PathValue(FalcorPath.From("foo", id, "name"), "Jill-" + id));
                return(Complete(results));
            };

            Get["foo"] = parameters => Complete(new PathValue(new FalcorPath("foo"), "bar"));
        }