private void ParseCookies(string val) { if (_cookies == null) { _cookies = new CookieList(); } var cookieStrings = val.SplitByAny(';', ',') .Where(x => !string.IsNullOrEmpty(x)); Cookie current = null; var version = 0; foreach (var str in cookieStrings) { if (str.StartsWith("$Version")) { version = int.Parse(str.Substring(str.IndexOf('=') + 1).Unquote(), CultureInfo.InvariantCulture); } else if (str.StartsWith("$Path") && current != null) { current.Path = str.Substring(str.IndexOf('=') + 1).Trim(); } else if (str.StartsWith("$Domain") && current != null) { current.Domain = str.Substring(str.IndexOf('=') + 1).Trim(); } else if (str.StartsWith("$Port") && current != null) { current.Port = str.Substring(str.IndexOf('=') + 1).Trim(); } else { if (current != null) { _cookies.Add(current); } current = new Cookie(); var idx = str.IndexOf('='); if (idx > 0) { current.Name = str.Substring(0, idx).Trim(); current.Value = str.Substring(idx + 1).Trim(); } else { current.Name = str.Trim(); current.Value = string.Empty; } current.Version = version; } } if (current != null) { _cookies.Add(current); } }
private void UserWantsToCreateCookie(object obj) { var neu = new Cookie() { Name = "NEU", Herstellung = DateTime.Now, Form = Form.Stern }; context.Cookies.Add(neu); CookieList.Add(neu); SelectedCookie = neu; }