-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
NameValueCollectionWrapper.cs
55 lines (46 loc) · 1.4 KB
/
NameValueCollectionWrapper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using Microsoft.AspNet.SignalR.Hosting;
namespace Microsoft.AspNet.SignalR.Tests.Common.Infrastructure
{
public class NameValueCollectionWrapper : INameValueCollection
{
private readonly NameValueCollection _collection;
public NameValueCollectionWrapper()
: this(new NameValueCollection())
{
}
public NameValueCollectionWrapper(NameValueCollection collection)
{
_collection = collection;
}
public string this[string key]
{
get { return _collection[key]; }
}
public IEnumerable<string> GetValues(string key)
{
return _collection.GetValues(key);
}
public string Get(string key)
{
return _collection.Get(key);
}
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
{
return GetEnumerable().GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
private IEnumerable<KeyValuePair<string, string>> GetEnumerable()
{
foreach (string key in _collection)
{
yield return new KeyValuePair<string, string>(key, _collection.Get(key));
}
}
}
}