public UriTemplate (string template, bool ignoreTrailingSlash, IDictionary<string,string> additionalDefaults)
{
if (template == null)
throw new ArgumentNullException ("template");
this.template = template;
IgnoreTrailingSlash = ignoreTrailingSlash;
Defaults = new Dictionary<string,string> (StringComparer.InvariantCultureIgnoreCase);
if (additionalDefaults != null)
foreach (var pair in additionalDefaults)
Defaults.Add (pair.Key, pair.Value);
string p = template;
// Trim scheme, host name and port if exist.
if (CultureInfo.InvariantCulture.CompareInfo.IsPrefix (template, "http")) {
int idx = template.IndexOf ('/', 8); // after "http://x" or "https://"
if (idx > 0)
p = template.Substring (idx);
}
int q = p.IndexOf ('?');
path = ParsePathTemplate (p, 0, q >= 0 ? q : p.Length);
if (q >= 0)
ParseQueryTemplate (p, q, p.Length);
else
query = empty_strings;
}