Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorJoe Dluzen <jdluzen@gmail.com>2010-12-04 10:05:53 +0300
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2010-12-05 01:27:15 +0300
commitc740b9646233f60ed9b0863a91eb6fce9cc350b7 (patch)
treeb8b64d0847dd88b65db80528889e4162685eaaca /mcs
parent2d9639a029dbcc82347cd88d167f15aef4e2d0d4 (diff)
Fix for #656021.
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/System.ServiceModel.Web/System/UriTemplate.cs22
1 files 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 7ea8192cd94..6f9e5b67472 100644
--- a/mcs/class/System.ServiceModel.Web/System/UriTemplate.cs
+++ b/mcs/class/System.ServiceModel.Web/System/UriTemplate.cs
@@ -138,18 +138,17 @@ namespace System
int src = 0;
StringBuilder sb = new StringBuilder (template.Length);
- BindByName (ref src, sb, path, nvc, dic, omitDefaults);
- BindByName (ref src, sb, query, nvc, dic, omitDefaults);
+ BindByName (ref src, sb, path, nvc, dic, omitDefaults, false);
+ BindByName (ref src, sb, query, nvc, dic, omitDefaults, true);
sb.Append (template.Substring (src));
return new Uri (baseAddress.ToString () + sb.ToString ());
}
- void BindByName (ref int src, StringBuilder sb, ReadOnlyCollection<string> names, NameValueCollection nvc, IDictionary<string,string> dic, bool omitDefaults)
+ void BindByName (ref int src, StringBuilder sb, ReadOnlyCollection<string> names, NameValueCollection nvc, IDictionary<string,string> 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 @@ namespace System
#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;
}
}