Inheritance: System.Collections.Specialized.NameValueCollection
コード例 #1
0
        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);
        }
コード例 #2
0
        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;
        }
コード例 #3
0
 internal void ToString_GeneratesCorrectOutput(HttpValueCollection input, string expectedOutput)
 {
     string actualOutput = input.ToString();
     Assert.Equal(expectedOutput, actualOutput);
 }