public void SetCollection <T>(string name, HeaderValues <T> value) { var e = GetEntryOrCreate(name); if (value == null) { e.BoundToCollection = null; e.ResetValuesToEmptyList(); return; } e.ReplaceValuesWith(value); e.BoundToCollection = value; return; }
public HeaderValues <T> GetCollection <T>(string name, char delimiter, char open, char close) { var e = GetEntryOrCreate(name); if (e.BoundToCollection == null) { List <string> elements = new List <string>(e.Values.Count); if (e.Values.Count == 1 && e.Values[0].Value.IndexOf(delimiter) != -1 && !Comparer.Equals(e.Name, "Set-Cookie")) { elements.AddRange(ParseMultiValue(e.Values[0].Value, delimiter, open, close)); } else { foreach (var x in e.Values) { elements.Add(x.Value); } } e.ResetValuesToEmptyList(); foreach (var item in elements) { e.Values.Add(new HeaderString <object>(item.Trim(), HeaderString.Source.GetCollection)); } var c = new HeaderValues <T>(e.Values); c.Delimiter = delimiter; e.BoundToCollection = c; } var collection = (HeaderValues <T>)e.BoundToCollection; collection.Delimiter = delimiter; collection.ToArray(); return(collection); }
public void ReplaceValuesWith <T>(HeaderValues <T> value) { this.Values = value.InternalValues; }