public static NameValueCollection Create(IEnumerable <KeyValuePair <string, string> > pairs) { var nvc = new HttpValueCollection(); // Ordering example: // k=A&j=B&k=C --> k:[A,C];j=[B]. foreach (KeyValuePair <string, string> kv in pairs) { ThrowIfMaxHttpCollectionKeysExceeded(nvc.Count); string key = kv.Key; if (key == null) { key = string.Empty; } string value = kv.Value; if (value == null) { value = string.Empty; } nvc.Add(key, value); } nvc.IsReadOnly = false; return(nvc); }
public static NameValueCollection Create(IEnumerable<KeyValuePair<string, string>> pairs) { var nvc = new HttpValueCollection(); // Ordering example: // k=A&j=B&k=C --> k:[A,C];j=[B]. foreach (KeyValuePair<string, string> kv in pairs) { ThrowIfMaxHttpCollectionKeysExceeded(nvc.Count); string key = kv.Key; if (key == null) { key = String.Empty; } string value = kv.Value; if (value == null) { value = String.Empty; } nvc.Add(key, value); } nvc.IsReadOnly = false; return nvc; }
internal void ToString_GeneratesCorrectOutput(HttpValueCollection input, string expectedOutput) { string actualOutput = input.ToString(); Assert.Equal(expectedOutput, actualOutput); }