Author: atsushi
Date: 2008-02-15 13:34:05 -0500 (Fri, 15 Feb 2008)
New Revision: 95784
Modified:
trunk/olive/class/System.ServiceModel.Web/System/ChangeLog
trunk/olive/class/System.ServiceModel.Web/System/UriTemplate.cs
trunk/olive/class/System.ServiceModel.Web/System/UriTemplateMatch.cs
trunk/olive/class/System.ServiceModel.Web/Test/System/ChangeLog
trunk/olive/class/System.ServiceModel.Web/Test/System/UriTemplateTest.cs
Log:
2008-02-15 Atsushi Enomoto <[EMAIL PROTECTED]>
* UriTemplateMatch.cs : implement everything but WildcardPathSegments.
* UriTemplate.cs : (Match) set RequestUri. Add match strings to
RelativePathSegments and QueryParameters.
* UriTemplateTest.cs : added not-working case to be fixed.
Modified: trunk/olive/class/System.ServiceModel.Web/System/ChangeLog
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/System/ChangeLog 2008-02-15
18:29:58 UTC (rev 95783)
+++ trunk/olive/class/System.ServiceModel.Web/System/ChangeLog 2008-02-15
18:34:05 UTC (rev 95784)
@@ -1,5 +1,11 @@
2008-02-15 Atsushi Enomoto <[EMAIL PROTECTED]>
+ * UriTemplateMatch.cs : implement everything but WildcardPathSegments.
+ * UriTemplate.cs : (Match) set RequestUri. Add match strings to
+ RelativePathSegments and QueryParameters.
+
+2008-02-15 Atsushi Enomoto <[EMAIL PROTECTED]>
+
* UriTemplateTable.cs : key_value_pair was not set.
* UriTemplate.cs : in Match(), template and candidate could start
from '/' which should not be compared.
Modified: trunk/olive/class/System.ServiceModel.Web/System/UriTemplate.cs
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/System/UriTemplate.cs
2008-02-15 18:29:58 UTC (rev 95783)
+++ trunk/olive/class/System.ServiceModel.Web/System/UriTemplate.cs
2008-02-15 18:34:05 UTC (rev 95784)
@@ -158,6 +158,7 @@
UriTemplateMatch m = new UriTemplateMatch ();
m.BaseUri = baseAddress;
m.Template = this;
+ m.RequestUri = candidate;
var vc = m.BoundVariables;
string cp = candidate.PathAndQuery;
@@ -178,6 +179,7 @@
ce = cp.Length;
string value = cp.Substring (c, ce - c);
vc [name] = value;
+ m.RelativePathSegments.Add (value);
c += value.Length;
}
foreach (string name in query) {
@@ -191,6 +193,7 @@
ce = cp.Length;
string value = cp.Substring (c, ce - c);
vc [name] = value;
+ m.QueryParameters.Add (name, value);
c += value.Length;
}
if ((cp.Length - c) != (template.Length - i) ||
Modified: trunk/olive/class/System.ServiceModel.Web/System/UriTemplateMatch.cs
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/System/UriTemplateMatch.cs
2008-02-15 18:29:58 UTC (rev 95783)
+++ trunk/olive/class/System.ServiceModel.Web/System/UriTemplateMatch.cs
2008-02-15 18:34:05 UTC (rev 95784)
@@ -37,10 +37,11 @@
{
}
- Uri base_uri;
- NameValueCollection nvc;
+ Uri base_uri, request_uri;
+ NameValueCollection nvc, query_params;
object data;
UriTemplate template;
+ Collection<string> path_segments;
public Uri BaseUri {
get { return base_uri; }
@@ -60,20 +61,25 @@
set { data = value; }
}
- [MonoTODO]
public NameValueCollection QueryParameters {
- get { throw new NotImplementedException (); }
+ get {
+ if (query_params == null)
+ query_params = new NameValueCollection
();
+ return query_params;
+ }
}
- [MonoTODO]
public Collection<string> RelativePathSegments {
- get { throw new NotImplementedException (); }
+ get {
+ if (path_segments == null)
+ path_segments = new Collection<string>
();
+ return path_segments;
+ }
}
- [MonoTODO]
public Uri RequestUri {
- get { throw new NotImplementedException (); }
- set { throw new NotImplementedException (); }
+ get { return request_uri; }
+ set { request_uri = value; }
}
public UriTemplate Template {
@@ -81,6 +87,7 @@
set { template = value; }
}
+ [MonoTODO]
public Collection<string> WildcardPathSegments {
get { throw new NotImplementedException (); }
}
Modified: trunk/olive/class/System.ServiceModel.Web/Test/System/ChangeLog
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/Test/System/ChangeLog
2008-02-15 18:29:58 UTC (rev 95783)
+++ trunk/olive/class/System.ServiceModel.Web/Test/System/ChangeLog
2008-02-15 18:34:05 UTC (rev 95784)
@@ -1,3 +1,7 @@
+2008-02-15 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * UriTemplateTest.cs : added not-working case to be fixed.
+
2008-02-12 Atsushi Enomoto <[EMAIL PROTECTED]>
* UriTemplateTest.cs : Added tests for Match() and more Binding tests.
Modified:
trunk/olive/class/System.ServiceModel.Web/Test/System/UriTemplateTest.cs
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/Test/System/UriTemplateTest.cs
2008-02-15 18:29:58 UTC (rev 95783)
+++ trunk/olive/class/System.ServiceModel.Web/Test/System/UriTemplateTest.cs
2008-02-15 18:34:05 UTC (rev 95784)
@@ -265,13 +265,24 @@
{
var t = new UriTemplate ("/{foo}/{bar}");
var n = new NameValueCollection ();
- Assert.IsNull (t.Match (new Uri ("http://localhost/"),
new Uri ("http://localhost/hooray")), "#1");
- Assert.IsNull (t.Match (new Uri ("http://localhost/"),
new Uri ("http://localhost/v1/v2/extra")), "#2");
- Assert.IsNull (t.Match (new Uri ("http://localhost/"),
new Uri ("http://localhost/1/2/")), "#3");
- UriTemplateMatch m = t.Match (new Uri
("http://localhost/"), new Uri ("http://localhost/foooo/baaar"));
+ Uri baseUri = new Uri ("http://localhost/");
+ Assert.IsNull (t.Match (baseUri, new Uri
("http://localhost/hooray")), "#1");
+ Assert.IsNull (t.Match (baseUri, new Uri
("http://localhost/v1/v2/extra")), "#2");
+ Assert.IsNull (t.Match (baseUri, new Uri
("http://localhost/1/2/")), "#3");
+ UriTemplateMatch m = t.Match (baseUri, new Uri
("http://localhost/foooo/baaar"));
Assert.IsNotNull (m, "#4");
Assert.AreEqual ("foooo", m.BoundVariables ["foo"],
"#5");
Assert.AreEqual ("baaar", m.BoundVariables ["bar"],
"#6");
}
+
+ [Test]
+ [Category ("NotWorking")]
+ public void Match2 ()
+ {
+ var t = new UriTemplate ("/{foo}/{bar}?p1={baz}");
+ var n = new NameValueCollection ();
+ Uri baseUri = new Uri ("http://localhost/");
+ Assert.IsNotNull (t.Match (baseUri, new Uri
("http://localhost/X/Y")));
+ }
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches