void ParseQueryTemplate (string template, int index, int end)
{
// template starts with '?'
string [] parameters = template.Substring (index + 1, end - index - 1).Split ('&');
List<string> list = null;
foreach (string parameter in parameters) {
string [] pair = parameter.Split ('=');
if (pair.Length != 2)
throw new FormatException ("Invalid URI query string format");
string pname = pair [0];
string pvalue = pair [1];
if (pvalue.Length >= 2 && pvalue [0] == '{' && pvalue [pvalue.Length - 1] == '}') {
string ptemplate = pvalue.Substring (1, pvalue.Length - 2).ToUpper (CultureInfo.InvariantCulture);
query_params.Add (pname, ptemplate);
if (list == null)
list = new List<string> ();
if (list.Contains (ptemplate) || (path != null && path.Contains (ptemplate)))
throw new InvalidOperationException (String.Format ("The URI template string contains duplicate template item {{'{0}'}}", pvalue));
list.Add (ptemplate);
}
}
query = list != null ? new ReadOnlyCollection<string> (list.ToArray ()) : empty_strings;
}
}