forked from PPolza/XServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQueryString.cs
43 lines (33 loc) · 1005 Bytes
/
QueryString.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace XServer
{
public class QueryString
{
public Dictionary<string, string> Entries { get; set; }
public QueryString(string s)
{
Entries = new Dictionary<string, string>();
if(s.Length >= 1)
if (s[0] == '?')
{
s = s.Remove(0, 1);
var combos = s.Split(new char[] { '&' }, StringSplitOptions.None);
foreach (var c in combos)
{
string f = "";
string f2 = "";
var str = c.Split(new string[] { "=" }, 2, StringSplitOptions.None);
if (str.Length >= 1)
f = str[0];
if (str.Length == 2)
f2 = str[1];
Entries[f] = f2;
}
}
}
}
}