Example #1
0
 public ResourceCollectionInfo(TextSyndicationContent title, Uri link, IEnumerable <CategoriesDocument> categories, IEnumerable <string> accepts)
     : this(title, link, categories, true)
 {
     if (accepts == null)
     {
         throw new ArgumentNullException("accepts");
     }
     foreach (var a in accepts)
     {
         Accepts.Add(a);
     }
 }
Example #2
0
        public async Task Group__CurrentWithInputAndNextWithoutInput__ShouldBeProcessed()
        {
            var input   = 4;
            var current = new Accepts <int>();
            var next    = new Empty();
            var group   = new ActivityGroup <int>(current, next);

            await group.ExecuteAsync(input, () => Task.CompletedTask, new System.Threading.CancellationToken());

            Assert.Equal(input, current.Value);
            Assert.True(next.Processed);
        }
Example #3
0
        public async Task FlowBuilder__WithInputAndNoOutput__SecondPart__ShouldBeProcessed()
        {
            var input  = "Hello world!";
            var output = new Accepts <string>();
            var flow   = FlowBuilder
                         .When <Returns <string, string>, string, string>(x => x.Selector = _ => _)
                         .Then(output)
                         .Build();

            await flow.ExecuteAsync(input, () => Task.CompletedTask, new System.Threading.CancellationToken());

            Assert.Equal(input, output.Value);
        }
Example #4
0
        public async Task FlowBuilder__WithInputAndNoOutput__FirstPart__ShouldBeProcessed()
        {
            var inputText = "Hello world!";
            var input     = new Accepts <string>();
            var output    = new Empty();
            var flow      = FlowBuilder
                            .When <Accepts <string>, string>(input)
                            .Then(output)
                            .Build();

            await flow.ExecuteAsync(inputText, () => Task.CompletedTask, new System.Threading.CancellationToken());

            Assert.Equal(inputText, input.Value);
            Assert.True(output.Processed);
        }
Example #5
0
        private async void DisplayRequest(Request request)
        {
            var headers = request.Headers ?? new List <Header>();

            var accept = headers.GetValue(Header.Accept);

            if (!Accepts.Contains(accept))
            {
                accept = Accepts.First();
            }

            var contentType = headers.GetValue(Header.ContentType);

            if (!ContentTypes.Contains(contentType))
            {
                contentType = ContentTypes.First();
            }

            headers = headers
                      .Where(h =>
                             !h.Name.Equals(Header.Accept, StringComparison.OrdinalIgnoreCase) &&
                             !h.Name.Equals(Header.AcceptEncoding, StringComparison.OrdinalIgnoreCase) &&
                             !h.Name.Equals(Header.ContentType, StringComparison.OrdinalIgnoreCase))
                      .ToList();

            headers.Add(new Header(Header.Accept, accept));
            headers.Add(new Header(Header.AcceptEncoding, Header.AcceptEncodingValue));
            headers.Add(new Header(Header.ContentType, contentType));

            SelectedMethod      = request.Method;
            Url                 = request.Url;
            SelectedAccept      = accept;
            RequestBody         = new TextDocument(await Prettify(request.Body, contentType));
            SelectedContentType = contentType;
            Headers             = new BindableCollection <Header>(headers.OrderBy(h => h.Name));
            HeaderName          = null;
            HeaderValue         = null;

            var token = request.NamedAuthorizationState;

            if (token == null || token.AuthorizationState == null)
            {
                SelectedToken = _anonymousToken;
            }
            else
            {
                if (Tokens.All(t => t.Guid != token.Guid))
                {
                    Tokens.Add(token);
                }

                SelectedToken = token;
            }

            var response    = request.Response;
            var hasResponse = response != null;

            if (!hasResponse)
            {
                ResponseBody = null;
                return;
            }

            ResponseTime        = request.ResponseTime;
            ResponseBody        = new TextDocument(await Prettify(response.Body, response.ContentType));
            ResponseContentType = response.ContentType;
            HttpStatusCode      = response.HttpStatusCode;
            ResponseHeaders     = new BindableCollection <Header>(response.Headers.OrderBy(h => h.Name));
        }
Example #6
0
 public bool CanAdd(Illustration item)
 {
     return(Accepts.All(x => item.Tags.Any(t => t.Name == x || t.TranslatedName == x)) && Rejects.All(x => item.Tags.All(t => t.Name != x && t.TranslatedName != x)));
 }