forked from siteserver/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLowerNameValueCollection.cs
More file actions
45 lines (35 loc) · 1.04 KB
/
Copy pathLowerNameValueCollection.cs
File metadata and controls
45 lines (35 loc) · 1.04 KB
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
using System.Collections.Generic;
using System.Collections.Specialized;
namespace SiteServer.Utils
{
public class LowerNameValueCollection
{
private readonly NameValueCollection _nvcLower;
public LowerNameValueCollection()
{
Keys = new List<string>();
_nvcLower = new NameValueCollection();
}
public void Set(string name, string value)
{
if (string.IsNullOrEmpty(name)) return;
_nvcLower.Set(name.ToLower(), value);
if (!Keys.Contains(name))
{
Keys.Add(name);
}
}
public string Get(string name)
{
return string.IsNullOrEmpty(name) ? null : _nvcLower.Get(name.ToLower());
}
public void Remove(string name)
{
if (string.IsNullOrEmpty(name)) return;
_nvcLower.Remove(name.ToLower());
Keys.Remove(name);
}
public List<string> Keys { get; }
public int Count => Keys.Count;
}
}