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


C# CookieBasedSessions.Load方法代碼示例

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


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

示例1: Should_return_blank_session_if_encrypted_data_modified

        public void Should_return_blank_session_if_encrypted_data_modified()
        {
            var inputValue = ValidHmac + ValidData.Substring(0, ValidData.Length - 1) + "Z";
            inputValue = HttpUtility.UrlEncode(inputValue);
            var store = new CookieBasedSessions(this.rijndaelEncryptionProvider, this.defaultHmacProvider, this.defaultObjectSerializer);
            var request = new Request("GET", "/", "http");
            request.Cookies.Add(store.CookieName, inputValue);

            var result = store.Load(request);

            result.Count.ShouldEqual(0);
        }
開發者ID:jbattermann,項目名稱:Nancy,代碼行數:12,代碼來源:CookieBasedSessionsFixture.cs

示例2: Should_return_blank_session_if_encrypted_data_are_invalid_but_contain_semicolon_when_decrypted

        public void Should_return_blank_session_if_encrypted_data_are_invalid_but_contain_semicolon_when_decrypted()
        {
            var bogusEncrypted = this.rijndaelEncryptionProvider.Encrypt("foo;bar");
            var inputValue = ValidHmac + bogusEncrypted;
            inputValue = HttpUtility.UrlEncode(inputValue);
            var store = new CookieBasedSessions(this.rijndaelEncryptionProvider, this.defaultHmacProvider, this.defaultObjectSerializer);
            var request = new Request("GET", "/", "http");
            request.Cookies.Add(store.CookieName, inputValue);

            var result = store.Load(request);

            result.Count.ShouldEqual(0);
        }
開發者ID:jbattermann,項目名稱:Nancy,代碼行數:13,代碼來源:CookieBasedSessionsFixture.cs

示例3: Should_be_able_to_load_an_object_previously_saved_to_session

        public void Should_be_able_to_load_an_object_previously_saved_to_session()
        {
            var response = new Response();
            var session = new Session(new Dictionary<string, object>());
            var payload = new DefaultSessionObjectFormatterFixture.Payload(27, true, "Test string");
            var store = new CookieBasedSessions(this.rijndaelEncryptionProvider, this.defaultHmacProvider, this.defaultObjectSerializer);
            session["testObject"] = payload;
            store.Save(session, response);
            var request = new Request("GET", "/", "http");
            request.Cookies.Add(Helpers.HttpUtility.UrlEncode(response.Cookies.First().Name), Helpers.HttpUtility.UrlEncode(response.Cookies.First().Value));

            var result = store.Load(request);

            result["testObject"].ShouldEqual(payload);
        }
開發者ID:jbattermann,項目名稱:Nancy,代碼行數:15,代碼來源:CookieBasedSessionsFixture.cs

示例4: Should_load_valid_test_data

        public void Should_load_valid_test_data()
        {
            var inputValue = ValidHmac + ValidData;
            inputValue = HttpUtility.UrlEncode(inputValue);
            var store = new CookieBasedSessions(this.rijndaelEncryptionProvider, this.defaultHmacProvider, this.defaultObjectSerializer);
            var request = new Request("GET", "/", "http");
            request.Cookies.Add(store.CookieName, inputValue);

            var result = store.Load(request);

            result.Count.ShouldEqual(1);
            result.First().Value.ShouldBeOfType(typeof(DefaultSessionObjectFormatterFixture.Payload));
        }
開發者ID:jbattermann,項目名稱:Nancy,代碼行數:13,代碼來源:CookieBasedSessionsFixture.cs

示例5: Should_call_formatter_on_load

        public void Should_call_formatter_on_load()
        {
            var fakeFormatter = A.Fake<IObjectSerializer>();
            A.CallTo(() => this.fakeEncryptionProvider.Decrypt("encryptedkey1=value1")).Returns("key1=value1;");
            var store = new CookieBasedSessions(this.fakeEncryptionProvider, this.fakeHmacProvider, fakeFormatter);
            var request = CreateRequest("encryptedkey1=value1", false);

            store.Load(request);

            A.CallTo(() => fakeFormatter.Deserialize("value1")).MustHaveHappened(Repeated.Exactly.Once);
        }
開發者ID:jbattermann,項目名稱:Nancy,代碼行數:11,代碼來源:CookieBasedSessionsFixture.cs

示例6: Should_load_an_empty_session_if_session_cookie_is_invalid

        public void Should_load_an_empty_session_if_session_cookie_is_invalid()
        {
          //given
          var inputValue = ValidHmac.Substring(0, 5); //invalid Hmac
          inputValue = HttpUtility.UrlEncode(inputValue);
          var store = new CookieBasedSessions(this.rijndaelEncryptionProvider, this.defaultHmacProvider, this.defaultObjectSerializer);
          var request = new Request("GET", "/", "http");
          request.Cookies.Add(store.CookieName, inputValue);

          //when
          var result = store.Load(request);

          //then
          result.Count.ShouldEqual(0);
        }
開發者ID:jbattermann,項目名稱:Nancy,代碼行數:15,代碼來源:CookieBasedSessionsFixture.cs

示例7: Should_return_blank_session_if_hmac_missing

        public void Should_return_blank_session_if_hmac_missing()
        {
            var inputValue = ValidData;
            inputValue = HttpUtility.UrlEncode(inputValue);
            var store = new CookieBasedSessions(this.aesEncryptionProvider, this.defaultHmacProvider, this.defaultObjectSerializer);
            var request = new Request("GET", "/", "http");
            request.Cookies.Add(store.CookieName, inputValue);

            var result = store.Load(request);

            result.Count.ShouldEqual(0);
        }
開發者ID:RadifMasud,項目名稱:Nancy,代碼行數:12,代碼來源:CookieBasedSessionsFixture.cs

示例8: Should_return_blank_session_if_hmac_changed

        public void Should_return_blank_session_if_hmac_changed()
        {
            var inputValue = "b" + ValidHmac.Substring(1) + ValidData;
            inputValue = HttpUtility.UrlEncode(inputValue);
            var store = new CookieBasedSessions(this.rijndaelEncryptionProvider, this.defaultHmacProvider, new DefaultObjectSerializer());
            var request = new Request("GET", "/", "http");
            request.Cookies.Add(CookieBasedSessions.GetCookieName(), inputValue);

            var result = store.Load(request);

            result.Count.ShouldEqual(0);
        }
開發者ID:rspacjer,項目名稱:Nancy,代碼行數:12,代碼來源:CookieBasedSessionsFixture.cs

示例9: LoadSession

        /// <summary>
        /// Loads the request session
        /// </summary>
        /// <param name="context">Nancy context</param>
        /// <param name="sessionStore">Session store</param>
        /// <returns>Always returns null</returns>
        private static Response LoadSession(NancyContext context, CookieBasedSessions sessionStore)
        {
            if (context.Request == null)
            {
                return null;
            }

            context.Request.Session = sessionStore.Load(context.Request);

            return null;
        }
開發者ID:rspacjer,項目名稱:Nancy,代碼行數:17,代碼來源:CookieBasedSessions.cs


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