/// <summary> /// Sets custom cookies from an array of lines. /// </summary> /// <param name="lines">The lines containing the colon-separated name and value of the cookies</param> public void SetCustomCookies(string[] lines) { CustomCookies.Clear(); foreach (var line in lines) { if (line.Contains(':')) { var split = line.Split(new[] { ':' }, 2); CustomCookies[split[0].Trim()] = split[1].Trim(); } } }
/// <summary> /// Builds a string containing custom cookies. /// </summary> /// <returns>One cookie per line, with name and value separated by a colon</returns> public string GetCustomCookies() { StringBuilder sb = new StringBuilder(); foreach (var pair in CustomCookies) { sb.Append($"{pair.Key}: {pair.Value}"); if (!pair.Equals(CustomCookies.Last())) { sb.Append(Environment.NewLine); } } return(sb.ToString()); }