當前位置: 首頁>>代碼示例>>C#>>正文


C# AfterPipeline.Invoke方法代碼示例

本文整理匯總了C#中AfterPipeline.Invoke方法的典型用法代碼示例。如果您正苦於以下問題:C# AfterPipeline.Invoke方法的具體用法?C# AfterPipeline.Invoke怎麽用?C# AfterPipeline.Invoke使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AfterPipeline的用法示例。


在下文中一共展示了AfterPipeline.Invoke方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Should_add_response_cookie_if_it_has_changed

        public void Should_add_response_cookie_if_it_has_changed()
        {
            var beforePipeline = new BeforePipeline();
            var afterPipeline = new AfterPipeline();
            var hooks = A.Fake<IApplicationPipelines>();
            A.CallTo(() => hooks.BeforeRequest).Returns(beforePipeline);
            A.CallTo(() => hooks.AfterRequest).Returns(afterPipeline);
            CookieBasedSessions.Enable(hooks, encryptionProvider, "this passphrase", "this is a salt").WithFormatter(new Fakes.FakeSessionObjectFormatter());
            var request = CreateRequest("encryptedkey1=value1");
            A.CallTo(() => this.encryptionProvider.Decrypt("encryptedkey1=value1", A<string>.Ignored, A<byte[]>.Ignored)).Returns("key1=value1;");
            var response = A.Fake<Response>();
            var nancyContext = new NancyContext() { Request = request, Response = response };
            beforePipeline.Invoke(nancyContext);
            request.Session["Testing"] = "Test";

            afterPipeline.Invoke(nancyContext);

            response.Cookies.Count.ShouldEqual(1);
        }
開發者ID:ToJans,項目名稱:Nancy,代碼行數:19,代碼來源:CookieBasedSessionsFixture.cs

示例2: Should_add_response_cookie_if_it_has_changed

        public void Should_add_response_cookie_if_it_has_changed()
        {
            var beforePipeline = new BeforePipeline();
            var afterPipeline = new AfterPipeline();
            var hooks = A.Fake<IApplicationPipelines>();
            A.CallTo(() => hooks.BeforeRequest).Returns(beforePipeline);
            A.CallTo(() => hooks.AfterRequest).Returns(afterPipeline);
            CookieBasedSessions.Enable(hooks, new CryptographyConfiguration(this.fakeEncryptionProvider, this.fakeHmacProvider)).WithSerializer(new Fakes.FakeObjectSerializer());
            var request = CreateRequest("encryptedkey1=value1");
            A.CallTo(() => this.fakeEncryptionProvider.Decrypt("encryptedkey1=value1")).Returns("key1=value1;");
            var response = A.Fake<Response>();
            var nancyContext = new NancyContext() { Request = request, Response = response };
            beforePipeline.Invoke(nancyContext);
            request.Session["Testing"] = "Test";

            afterPipeline.Invoke(nancyContext);

            response.Cookies.Count.ShouldEqual(1);
        }
開發者ID:rspacjer,項目名稱:Nancy,代碼行數:19,代碼來源:CookieBasedSessionsFixture.cs

示例3: When_cast_to_func_and_invoked_members_are_invoked

        public void When_cast_to_func_and_invoked_members_are_invoked()
        {
            var item1Called = false;
            Action<NancyContext> item1 = (r) => { item1Called = true; };
            var item2Called = false;
            Action<NancyContext> item2 = (r) => { item2Called = true; };
            var item3Called = false;
            Action<NancyContext> item3 = (r) => { item3Called = true; };
            pipeline.AddItemToEndOfPipeline(item1);
            pipeline.AddItemToEndOfPipeline(item2);
            pipeline.AddItemToEndOfPipeline(item3);

            Action<NancyContext> action = context => { };
            pipeline += action;

            pipeline.Invoke(CreateContext(), CancellationToken.None);

            Assert.True(item1Called);
            Assert.True(item2Called);
            Assert.True(item3Called);
        }
開發者ID:JulianRooze,項目名稱:Nancy,代碼行數:21,代碼來源:AfterPipelineFixture.cs

示例4: Pipeline_containing_another_pipeline_will_invoke_items_in_both_pipelines

        public void Pipeline_containing_another_pipeline_will_invoke_items_in_both_pipelines()
        {
            var item1Called = false;
            Action<NancyContext> item1 = (r) => { item1Called = true; };
            var item2Called = false;
            Action<NancyContext> item2 = (r) => { item2Called = true; };
            var item3Called = false;
            Action<NancyContext> item3 = (r) => { item3Called = true; };
            var item4Called = false;
            Action<NancyContext> item4 = (r) => { item4Called = true; };
            pipeline += item1;
            pipeline += item2;
            var subPipeline = new AfterPipeline();
            subPipeline += item3;
            subPipeline += item4;

            pipeline.AddItemToEndOfPipeline(subPipeline);
            pipeline.Invoke(CreateContext());

            Assert.True(item1Called);
            Assert.True(item2Called);
            Assert.True(item3Called);
            Assert.True(item4Called);
        }
開發者ID:nuxleus,項目名稱:Nancy,代碼行數:24,代碼來源:PostRequestHooksPipelineFixture.cs

示例5: ExecutePost

        private void ExecutePost(NancyContext context, CancellationToken cancellationToken, AfterPipeline postHook, TaskCompletionSource<Response> tcs)
        {
            if (postHook == null)
            {
                tcs.SetResult(context.Response);
                return;
            }

            postHook.Invoke(context, cancellationToken).WhenCompleted(
                                        t => tcs.SetResult(context.Response),
                                        t => tcs.SetException(t.Exception),
                                        false);
        }
開發者ID:randacc,項目名稱:Nancy,代碼行數:13,代碼來源:DefaultRequestDispatcher.cs

示例6: ExecutePost

        private static void ExecutePost(NancyContext context, CancellationToken cancellationToken, AfterPipeline postHook, Func<NancyContext, Exception, Response> onError, TaskCompletionSource<Response> tcs)
        {
            if (postHook == null)
            {
                tcs.SetResult(context.Response);
                return;
            }

            postHook.Invoke(context, cancellationToken).WhenCompleted(
                completedTask => tcs.SetResult(context.Response),
                completedTask => HandlePostHookFaultedTask(context, onError, completedTask, tcs),
                false);
        }
開發者ID:adglopez,項目名稱:Nancy,代碼行數:13,代碼來源:DefaultRequestDispatcher.cs

示例7: ExecutePost

        private async Task ExecutePost(NancyContext context, CancellationToken cancellationToken, AfterPipeline postHook, Func<NancyContext, Exception, dynamic> onError)
        {
            if (postHook == null)
            {
                return;
            }

            try
            {
                await postHook.Invoke(context, cancellationToken)
                    .ConfigureAwait(false);
            }
            catch(Exception ex)
            {
                context.Response = this.ResolveErrorResult(context, onError, ex);

                if(context.Response == null)
                {
                    throw;
                }
            }
        }
開發者ID:RadifMasud,項目名稱:Nancy,代碼行數:22,代碼來源:DefaultRequestDispatcher.cs


注:本文中的AfterPipeline.Invoke方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。