Пример #1
0
        public void silly_with_works()
        {
            var state = new CookieState("key").With("a", "1").With("b", "2");

            state["a"].ShouldBe("1");
            state["b"].ShouldBe("2");
        }
Пример #2
0
        public static Cookie ToCookie(string headerValue)
        {
            if (headerValue.IsEmpty())
            {
                return(null);
            }

            var cookie = new Cookie();

            var segments = headerValue.TrimEnd().TrimEnd(';').Split(';').Select(x => new Segment(x.Trim()));

            segments.Each(segment => {
                string canonicalKey = segment.Key.ToLowerInvariant();

                if (_setters.Has(canonicalKey))
                {
                    _setters[canonicalKey](cookie, segment.Value);
                }
                else
                {
                    var state = CookieState.For(segment);
                    cookie.Add(state);
                }
            });

            return(cookie);
        }
Пример #3
0
 public Cookie(string name, string value)
 {
     var state = new CookieState(name, value);
     _states.Add(state);
 }
Пример #4
0
 public Cookie Add(CookieState state)
 {
     _states.Add(state);
     return this;
 }
Пример #5
0
        public Cookie(string name, string value)
        {
            var state = new CookieState(name, value);

            _states.Add(state);
        }
Пример #6
0
 public Cookie Add(CookieState state)
 {
     _states.Add(state);
     return(this);
 }