コード例 #1
0
        public static Links StreamBrowserNavigation(
            this Links links,
            ListStreamsPage listStreamsPage,
            ListStreamsOperation operation)
        {
            if (operation.ContinuationToken != null)
            {
                links.Add(
                    Constants.Relations.Next,
                    LinkFormatter.ListStreams(operation.Pattern, operation.MaxCount, operation.ContinuationToken));
            }

            if (listStreamsPage.ContinuationToken != null)
            {
                links.Add(
                    Constants.Relations.Next,
                    LinkFormatter.ListStreams(operation.Pattern, operation.MaxCount, operation.ContinuationToken));
            }


            return(links
                   .Add(
                       Constants.Relations.Browse,
                       LinkFormatter.ListStreams(operation.Pattern, operation.MaxCount, operation.ContinuationToken))
                   .Self());
        }
コード例 #2
0
        public async Task <Response> Get(ListStreamsOperation operation, CancellationToken cancellationToken)
        {
            var listStreamsPage = await operation.Invoke(_streamStore, cancellationToken);

            return(new HalJsonResponse(new HALResponse(new
            {
                listStreamsPage.ContinuationToken
            })
                                       .AddLinks(
                                           Links
                                           .FromOperation(operation)
                                           .Index()
                                           .Find()
                                           .StreamBrowserNavigation(listStreamsPage, operation))
                                       .AddEmbeddedCollection(
                                           Constants.Relations.Feed,
                                           Array.ConvertAll(
                                               listStreamsPage.StreamIds,
                                               streamId => new HALResponse(null)
                                               .AddLinks(
                                                   Links
                                                   .FromOperation(operation)
                                                   .Add(Constants.Relations.Feed, LinkFormatter.Stream(streamId), streamId)
                                                   .Self())))));
        }
コード例 #3
0
 private static string FormatLink(ListStreamsOperation operation, string continuationToken) =>
 $"streams?p={operation.Pattern.Value}&t={operation.PatternType}&c={continuationToken}&m={operation.MaxCount}";