From b26531ebba147d0cfbfa8eaa0858d99247ee6bb1 Mon Sep 17 00:00:00 2001 From: Joe Dluzen Date: Sat, 4 Dec 2010 02:05:53 -0500 Subject: [PATCH] Fix for #656021. --- .../System/UriTemplate.cs | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/mcs/class/System.ServiceModel.Web/System/UriTemplate.cs b/mcs/class/System.ServiceModel.Web/System/UriTemplate.cs index 7ea8192cd941..6f9e5b674722 100644 --- a/mcs/class/System.ServiceModel.Web/System/UriTemplate.cs +++ b/mcs/class/System.ServiceModel.Web/System/UriTemplate.cs @@ -138,18 +138,17 @@ Uri BindByNameCommon (Uri baseAddress, NameValueCollection nvc, IDictionary names, NameValueCollection nvc, IDictionary dic, bool omitDefaults) + void BindByName (ref int src, StringBuilder sb, ReadOnlyCollection names, NameValueCollection nvc, IDictionary dic, bool omitDefaults, bool query) { foreach (string name in names) { int s = template.IndexOf ('{', src); int e = template.IndexOf ('}', s + 1); - sb.Append (template.Substring (src, s - src)); #if NET_2_1 string value = null; #else @@ -157,9 +156,18 @@ void BindByName (ref int src, StringBuilder sb, ReadOnlyCollection names #endif if (dic != null) dic.TryGetValue (name, out value); - if (value == null && (omitDefaults || !Defaults.TryGetValue (name, out value))) - throw new ArgumentException (String.Format ("The argument name value collection does not contain non-null value for '{0}'", name), "parameters"); - sb.Append (value); + if (query) { + if (value != null || (!omitDefaults && Defaults.TryGetValue (name, out value))) { + sb.Append (template.Substring (src, s - src)); + sb.Append (value); + } + } else + if (value == null && (omitDefaults || !Defaults.TryGetValue(name, out value))) + throw new ArgumentException(string.Format("The argument name value collection does not contain non-nul vaalue for '{0}'", name), "parameters"); + else { + sb.Append (template.Substring (src, s - src)); + sb.Append (value); + } src = e + 1; } }