Exemple #1
0
        private string CreateHref(PaperContext ctx, T paper)
        {
            var paperInfo     = PaperSpec.GetSpec <T>();
            var paperTemplate = new UriTemplate(paperInfo.Route);

            paperTemplate.SetArgsFromGraph(paper);

            var uri       = paperTemplate.CreateUri();
            var targetUri = new Route(uri);

            targetUri = targetUri.SetArg(
                "f", ctx.PathArgs["f"],
                "in", ctx.PathArgs["in"],
                "out", ctx.PathArgs["out"]
                );

            var filter = paper._Get <IFilter>("Filter");

            if (filter != null)
            {
                var map  = new FieldMap(filter);
                var args = (
                    from field in map
                    where field.Value != null
                    select new[] {
                    field.Key.ChangeCase(TextCase.CamelCase),
                    field.Value
                }
                    ).SelectMany();
                targetUri = targetUri.SetArg(args);
            }

            return(targetUri.ToString());
        }