public static StringDictionary ParseQuery(String query)
{
StringDictionary map = new StringDictionary();
if(String.IsNullOrEmpty(query))
{
return EmptyMap;
}
// strip the initial "?"
if(query.StartsWith("?"))
{
query = query.Substring(1);
}
// split the query into parameters
string[] parameters = query.Split('&');
foreach(string pair in parameters)
{
if(pair.Length > 0)
{
string[] nameValue = pair.Split('=');
if(nameValue.Length != 2)
{
throw new NMSException(string.Format("Invalid Uri parameter: {0}", query));
}
map[nameValue[0]] = nameValue[1];
}
}
return map;
}