From d73f223a74b910a8754ab42ea79430bc9523ed68 Mon Sep 17 00:00:00 2001 From: bbaia Date: Tue, 4 Jan 2011 11:44:39 +0000 Subject: [PATCH] REST client API: Use 'object' instead of 'string' for UriTemplate variables (SPRNET-1345) --- .../Http/Rest/IRestAsyncOperations.cs | 52 ++++----- .../Spring.Http/Http/Rest/IRestOperations.cs | 52 ++++----- .../Spring.Http/Http/Rest/RestTemplate.cs | 108 +++++++++--------- src/Spring/Spring.Http/Util/UriTemplate.cs | 14 +-- .../Http/Rest/RestTemplateIntegrationTests.cs | 10 +- .../Util/UriTemplateTests.cs | 24 ++-- 6 files changed, 130 insertions(+), 130 deletions(-) diff --git a/src/Spring/Spring.Http/Http/Rest/IRestAsyncOperations.cs b/src/Spring/Spring.Http/Http/Rest/IRestAsyncOperations.cs index 28df06cd..dcf3b8c7 100644 --- a/src/Spring/Spring.Http/Http/Rest/IRestAsyncOperations.cs +++ b/src/Spring/Spring.Http/Http/Rest/IRestAsyncOperations.cs @@ -50,7 +50,7 @@ namespace Spring.Http.Rest /// The URL. /// The variables to expand the template. /// The converted object - void GetForObjectAsync(string url, string[] uriVariables, Action> getCompleted) where T : class; + void GetForObjectAsync(string url, object[] uriVariables, Action> getCompleted) where T : class; /// /// Retrieve a representation by doing a GET on the specified URL. @@ -63,7 +63,7 @@ namespace Spring.Http.Rest /// The URL. /// The dictionary containing variables for the URI template. /// The converted object - void GetForObjectAsync(string url, IDictionary uriVariables, Action> getCompleted) where T : class; + void GetForObjectAsync(string url, IDictionary uriVariables, Action> getCompleted) where T : class; /// /// Retrieve a representation by doing a GET on the specified URL. @@ -85,7 +85,7 @@ namespace Spring.Http.Rest /// The URL. /// The variables to expand the template. /// The HTTP response message. - void GetForMessageAsync(string url, string[] uriVariables, Action>> getCompleted) where T : class; + void GetForMessageAsync(string url, object[] uriVariables, Action>> getCompleted) where T : class; /// /// Retrieve an entity by doing a GET on the specified URL. @@ -98,7 +98,7 @@ namespace Spring.Http.Rest /// The URL. /// The dictionary containing variables for the URI template. /// The HTTP response message. - void GetForMessageAsync(string url, IDictionary uriVariables, Action>> getCompleted) where T : class; + void GetForMessageAsync(string url, IDictionary uriVariables, Action>> getCompleted) where T : class; /// /// Retrieve an entity by doing a GET on the specified URL. @@ -122,7 +122,7 @@ namespace Spring.Http.Rest /// The URL. /// The variables to expand the template. /// All HTTP headers of that resource - void HeadForHeadersAsync(string url, string[] uriVariables, Action> headCompleted); + void HeadForHeadersAsync(string url, object[] uriVariables, Action> headCompleted); /// /// Retrieve all headers of the resource specified by the URI template. @@ -133,7 +133,7 @@ namespace Spring.Http.Rest /// The URL. /// The dictionary containing variables for the URI template. /// All HTTP headers of that resource - void HeadForHeadersAsync(string url, IDictionary uriVariables, Action> headCompleted); + void HeadForHeadersAsync(string url, IDictionary uriVariables, Action> headCompleted); /// /// Retrieve all headers of the resource specified by the URI template. @@ -163,7 +163,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The variables to expand the template. /// The value for the Location header. - void PostForLocationAsync(string url, object request, string[] uriVariables, Action postCompleted); + void PostForLocationAsync(string url, object request, object[] uriVariables, Action postCompleted); /// /// Create a new resource by POSTing the given object to the URI template, @@ -182,7 +182,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The dictionary containing variables for the URI template. /// The value for the Location header. - void PostForLocationAsync(string url, object request, IDictionary uriVariables, Action postCompleted); + void PostForLocationAsync(string url, object request, IDictionary uriVariables, Action postCompleted); /// /// Create a new resource by POSTing the given object to the URI template, @@ -214,7 +214,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The variables to expand the template. /// The converted object. - void PostForObjectAsync(string url, object request, string[] uriVariables, Action> postCompleted) where T : class; + void PostForObjectAsync(string url, object request, object[] uriVariables, Action> postCompleted) where T : class; /// /// Create a new resource by POSTing the given object to the URI template, @@ -233,7 +233,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The dictionary containing variables for the URI template. /// The converted object. - void PostForObjectAsync(string url, object request, IDictionary uriVariables, Action> postCompleted) where T : class; + void PostForObjectAsync(string url, object request, IDictionary uriVariables, Action> postCompleted) where T : class; /// /// Create a new resource by POSTing the given object to the URI template, @@ -265,7 +265,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The variables to expand the template. /// The HTTP response message. - void PostForMessageAsync(string url, object request, string[] uriVariables, Action>> postCompleted) where T : class; + void PostForMessageAsync(string url, object request, object[] uriVariables, Action>> postCompleted) where T : class; /// /// Create a new resource by POSTing the given object to the URI template, @@ -284,7 +284,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The dictionary containing variables for the URI template. /// The HTTP response message. - void PostForMessageAsync(string url, object request, IDictionary uriVariables, Action>> postCompleted) where T : class; + void PostForMessageAsync(string url, object request, IDictionary uriVariables, Action>> postCompleted) where T : class; /// /// Create a new resource by POSTing the given object to the URI template, @@ -315,7 +315,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The variables to expand the template. /// The HTTP response message with no entity. - void PostForMessageAsync(string url, object request, string[] uriVariables, Action> postCompleted); + void PostForMessageAsync(string url, object request, object[] uriVariables, Action> postCompleted); /// /// Create a new resource by POSTing the given object to the URI template, @@ -333,7 +333,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The dictionary containing variables for the URI template. /// The HTTP response message with no entity. - void PostForMessageAsync(string url, object request, IDictionary uriVariables, Action> postCompleted); + void PostForMessageAsync(string url, object request, IDictionary uriVariables, Action> postCompleted); /// /// Create a new resource by POSTing the given object to the URI template, @@ -365,7 +365,7 @@ namespace Spring.Http.Rest /// The URL. /// The Object to be PUT, may be null. /// The variables to expand the template. - void PutAsync(string url, object request, string[] uriVariables, Action> putCompleted); + void PutAsync(string url, object request, object[] uriVariables, Action> putCompleted); /// /// Create or update a resource by PUTting the given object to the URI. @@ -381,7 +381,7 @@ namespace Spring.Http.Rest /// The URL. /// The Object to be PUT, may be null. /// The dictionary containing variables for the URI template. - void PutAsync(string url, object request, IDictionary uriVariables, Action> putCompleted); + void PutAsync(string url, object request, IDictionary uriVariables, Action> putCompleted); /// /// Create or update a resource by PUTting the given object to the URI. @@ -405,7 +405,7 @@ namespace Spring.Http.Rest /// /// The URL. /// The variables to expand the template. - void DeleteAsync(string url, string[] uriVariables, Action> deleteCompleted); + void DeleteAsync(string url, object[] uriVariables, Action> deleteCompleted); /// /// Delete the resources at the specified URI. @@ -415,7 +415,7 @@ namespace Spring.Http.Rest /// /// The URL. /// The dictionary containing variables for the URI template. - void DeleteAsync(string url, IDictionary uriVariables, Action> deleteCompleted); + void DeleteAsync(string url, IDictionary uriVariables, Action> deleteCompleted); /// /// Delete the resources at the specified URI. @@ -436,7 +436,7 @@ namespace Spring.Http.Rest /// The URL. /// The variables to expand the template. /// The value of the allow header. - void OptionsForAllowAsync(string url, string[] uriVariables, Action> optionsCompleted); + void OptionsForAllowAsync(string url, object[] uriVariables, Action> optionsCompleted); /// /// Return the value of the Allow header for the given URI. @@ -447,7 +447,7 @@ namespace Spring.Http.Rest /// The URL. /// The dictionary containing variables for the URI template. /// The value of the allow header. - void OptionsForAllowAsync(string url, IDictionary uriVariables, Action> optionsCompleted); + void OptionsForAllowAsync(string url, IDictionary uriVariables, Action> optionsCompleted); /// /// Return the value of the Allow header for the given URI. @@ -476,7 +476,7 @@ namespace Spring.Http.Rest /// /// The variables to expand the template. /// The HTTP response message. - void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, string[] uriVariables, Action>> methodCompleted) where T : class; + void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, object[] uriVariables, Action>> methodCompleted) where T : class; /// /// Execute the HTTP method to the given URI template, writing the given request message to the request, @@ -493,7 +493,7 @@ namespace Spring.Http.Rest /// /// The dictionary containing variables for the URI template. /// The HTTP response message. - void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables, Action>> methodCompleted) where T : class; + void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables, Action>> methodCompleted) where T : class; /// /// Execute the HTTP method to the given URI template, writing the given request message to the request, @@ -522,7 +522,7 @@ namespace Spring.Http.Rest /// /// The variables to expand the template. /// The HTTP response message with no entity. - void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, string[] uriVariables, Action> methodCompleted); + void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, object[] uriVariables, Action> methodCompleted); /// /// Execute the HTTP method to the given URI template, writing the given request message to the request, @@ -538,7 +538,7 @@ namespace Spring.Http.Rest /// /// The dictionary containing variables for the URI template. /// The HTTP response message with no entity. - void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables, Action> methodCompleted); + void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables, Action> methodCompleted); /// /// Execute the HTTP method to the given URI template, writing the given request message to the request, @@ -570,7 +570,7 @@ namespace Spring.Http.Rest /// Object that extracts the return value from the response. /// The variables to expand the template. /// An arbitrary object, as returned by the . - void ExecuteAsync(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, string[] uriVariables, Action> methodCompleted) where T : class; + void ExecuteAsync(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, object[] uriVariables, Action> methodCompleted) where T : class; /// /// Execute the HTTP method to the given URI template, preparing the request with the @@ -586,7 +586,7 @@ namespace Spring.Http.Rest /// Object that extracts the return value from the response. /// The dictionary containing variables for the URI template. /// An arbitrary object, as returned by the . - void ExecuteAsync(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, IDictionary uriVariables, Action> methodCompleted) where T : class; + void ExecuteAsync(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, IDictionary uriVariables, Action> methodCompleted) where T : class; /// /// Execute the HTTP method to the given URI template, preparing the request with the diff --git a/src/Spring/Spring.Http/Http/Rest/IRestOperations.cs b/src/Spring/Spring.Http/Http/Rest/IRestOperations.cs index 01cec0b1..2e1fcecf 100644 --- a/src/Spring/Spring.Http/Http/Rest/IRestOperations.cs +++ b/src/Spring/Spring.Http/Http/Rest/IRestOperations.cs @@ -54,7 +54,7 @@ namespace Spring.Http.Rest /// The URL. /// The variables to expand the template. /// The converted object - T GetForObject(string url, params string[] uriVariables) where T : class; + T GetForObject(string url, params object[] uriVariables) where T : class; /// /// Retrieve a representation by doing a GET on the specified URL. @@ -67,7 +67,7 @@ namespace Spring.Http.Rest /// The URL. /// The dictionary containing variables for the URI template. /// The converted object - T GetForObject(string url, IDictionary uriVariables) where T : class; + T GetForObject(string url, IDictionary uriVariables) where T : class; /// /// Retrieve a representation by doing a GET on the specified URL. @@ -89,7 +89,7 @@ namespace Spring.Http.Rest /// The URL. /// The variables to expand the template. /// The HTTP response message. - HttpResponseMessage GetForMessage(string url, params string[] uriVariables) where T : class; + HttpResponseMessage GetForMessage(string url, params object[] uriVariables) where T : class; /// /// Retrieve an entity by doing a GET on the specified URL. @@ -102,7 +102,7 @@ namespace Spring.Http.Rest /// The URL. /// The dictionary containing variables for the URI template. /// The HTTP response message. - HttpResponseMessage GetForMessage(string url, IDictionary uriVariables) where T : class; + HttpResponseMessage GetForMessage(string url, IDictionary uriVariables) where T : class; /// /// Retrieve an entity by doing a GET on the specified URL. @@ -126,7 +126,7 @@ namespace Spring.Http.Rest /// The URL. /// The variables to expand the template. /// All HTTP headers of that resource - HttpHeaders HeadForHeaders(string url, params string[] uriVariables); + HttpHeaders HeadForHeaders(string url, params object[] uriVariables); /// /// Retrieve all headers of the resource specified by the URI template. @@ -137,7 +137,7 @@ namespace Spring.Http.Rest /// The URL. /// The dictionary containing variables for the URI template. /// All HTTP headers of that resource - HttpHeaders HeadForHeaders(string url, IDictionary uriVariables); + HttpHeaders HeadForHeaders(string url, IDictionary uriVariables); /// /// Retrieve all headers of the resource specified by the URI template. @@ -167,7 +167,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The variables to expand the template. /// The value for the Location header. - Uri PostForLocation(string url, object request, params string[] uriVariables); + Uri PostForLocation(string url, object request, params object[] uriVariables); /// /// Create a new resource by POSTing the given object to the URI template, @@ -186,7 +186,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The dictionary containing variables for the URI template. /// The value for the Location header. - Uri PostForLocation(string url, object request, IDictionary uriVariables); + Uri PostForLocation(string url, object request, IDictionary uriVariables); /// /// Create a new resource by POSTing the given object to the URI template, @@ -218,7 +218,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The variables to expand the template. /// The converted object. - T PostForObject(string url, object request, params string[] uriVariables) where T : class; + T PostForObject(string url, object request, params object[] uriVariables) where T : class; /// /// Create a new resource by POSTing the given object to the URI template, @@ -237,7 +237,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The dictionary containing variables for the URI template. /// The converted object. - T PostForObject(string url, object request, IDictionary uriVariables) where T : class; + T PostForObject(string url, object request, IDictionary uriVariables) where T : class; /// /// Create a new resource by POSTing the given object to the URI template, @@ -269,7 +269,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The variables to expand the template. /// The HTTP response message. - HttpResponseMessage PostForMessage(string url, object request, params string[] uriVariables) where T : class; + HttpResponseMessage PostForMessage(string url, object request, params object[] uriVariables) where T : class; /// /// Create a new resource by POSTing the given object to the URI template, @@ -288,7 +288,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The dictionary containing variables for the URI template. /// The HTTP response message. - HttpResponseMessage PostForMessage(string url, object request, IDictionary uriVariables) where T : class; + HttpResponseMessage PostForMessage(string url, object request, IDictionary uriVariables) where T : class; /// /// Create a new resource by POSTing the given object to the URI template, @@ -319,7 +319,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The variables to expand the template. /// The HTTP response message with no entity. - HttpResponseMessage PostForMessage(string url, object request, params string[] uriVariables); + HttpResponseMessage PostForMessage(string url, object request, params object[] uriVariables); /// /// Create a new resource by POSTing the given object to the URI template, @@ -337,7 +337,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The dictionary containing variables for the URI template. /// The HTTP response message with no entity. - HttpResponseMessage PostForMessage(string url, object request, IDictionary uriVariables); + HttpResponseMessage PostForMessage(string url, object request, IDictionary uriVariables); /// /// Create a new resource by POSTing the given object to the URI template, @@ -369,7 +369,7 @@ namespace Spring.Http.Rest /// The URL. /// The Object to be PUT, may be null. /// The variables to expand the template. - void Put(string url, object request, params string[] uriVariables); + void Put(string url, object request, params object[] uriVariables); /// /// Create or update a resource by PUTting the given object to the URI. @@ -385,7 +385,7 @@ namespace Spring.Http.Rest /// The URL. /// The Object to be PUT, may be null. /// The dictionary containing variables for the URI template. - void Put(string url, object request, IDictionary uriVariables); + void Put(string url, object request, IDictionary uriVariables); /// /// Create or update a resource by PUTting the given object to the URI. @@ -409,7 +409,7 @@ namespace Spring.Http.Rest /// /// The URL. /// The variables to expand the template. - void Delete(string url, params string[] uriVariables); + void Delete(string url, params object[] uriVariables); /// /// Delete the resources at the specified URI. @@ -419,7 +419,7 @@ namespace Spring.Http.Rest /// /// The URL. /// The dictionary containing variables for the URI template. - void Delete(string url, IDictionary uriVariables); + void Delete(string url, IDictionary uriVariables); /// /// Delete the resources at the specified URI. @@ -440,7 +440,7 @@ namespace Spring.Http.Rest /// The URL. /// The variables to expand the template. /// The value of the allow header. - IList OptionsForAllow(string url, params string[] uriVariables); + IList OptionsForAllow(string url, params object[] uriVariables); /// /// Return the value of the Allow header for the given URI. @@ -451,7 +451,7 @@ namespace Spring.Http.Rest /// The URL. /// The dictionary containing variables for the URI template. /// The value of the allow header. - IList OptionsForAllow(string url, IDictionary uriVariables); + IList OptionsForAllow(string url, IDictionary uriVariables); /// /// Return the value of the Allow header for the given URI. @@ -480,7 +480,7 @@ namespace Spring.Http.Rest /// /// The variables to expand the template. /// The HTTP response message. - HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, params string[] uriVariables) where T : class; + HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, params object[] uriVariables) where T : class; /// /// Execute the HTTP method to the given URI template, writing the given request message to the request, @@ -497,7 +497,7 @@ namespace Spring.Http.Rest /// /// The dictionary containing variables for the URI template. /// The HTTP response message. - HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables) where T : class; + HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables) where T : class; /// /// Execute the HTTP method to the given URI template, writing the given request message to the request, @@ -526,7 +526,7 @@ namespace Spring.Http.Rest /// /// The variables to expand the template. /// The HTTP response message with no entity. - HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, params string[] uriVariables); + HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, params object[] uriVariables); /// /// Execute the HTTP method to the given URI template, writing the given request message to the request, @@ -542,7 +542,7 @@ namespace Spring.Http.Rest /// /// The dictionary containing variables for the URI template. /// The HTTP response message with no entity. - HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables); + HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables); /// /// Execute the HTTP method to the given URI template, writing the given request message to the request, @@ -574,7 +574,7 @@ namespace Spring.Http.Rest /// Object that extracts the return value from the response. /// The variables to expand the template. /// An arbitrary object, as returned by the . - T Execute(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, params string[] uriVariables) where T : class; + T Execute(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, params object[] uriVariables) where T : class; /// /// Execute the HTTP method to the given URI template, preparing the request with the @@ -590,7 +590,7 @@ namespace Spring.Http.Rest /// Object that extracts the return value from the response. /// The dictionary containing variables for the URI template. /// An arbitrary object, as returned by the . - T Execute(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, IDictionary uriVariables) where T : class; + T Execute(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, IDictionary uriVariables) where T : class; /// /// Execute the HTTP method to the given URI template, preparing the request with the diff --git a/src/Spring/Spring.Http/Http/Rest/RestTemplate.cs b/src/Spring/Spring.Http/Http/Rest/RestTemplate.cs index 7529ee0e..f37d1eba 100644 --- a/src/Spring/Spring.Http/Http/Rest/RestTemplate.cs +++ b/src/Spring/Spring.Http/Http/Rest/RestTemplate.cs @@ -268,7 +268,7 @@ namespace Spring.Http.Rest /// The URL. /// The variables to expand the template. /// The converted object - public T GetForObject(string url, params string[] uriVariables) where T : class + public T GetForObject(string url, params object[] uriVariables) where T : class { AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(typeof(T), this._messageConverters); MessageConverterResponseExtractor responseExtractor = new MessageConverterResponseExtractor(this._messageConverters); @@ -286,7 +286,7 @@ namespace Spring.Http.Rest /// The URL. /// The dictionary containing variables for the URI template. /// The converted object - public T GetForObject(string url, IDictionary uriVariables) where T : class + public T GetForObject(string url, IDictionary uriVariables) where T : class { AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(typeof(T), this._messageConverters); MessageConverterResponseExtractor responseExtractor = new MessageConverterResponseExtractor(this._messageConverters); @@ -318,7 +318,7 @@ namespace Spring.Http.Rest /// The URL. /// The variables to expand the template. /// The HTTP response message. - public HttpResponseMessage GetForMessage(string url, params string[] uriVariables) where T : class + public HttpResponseMessage GetForMessage(string url, params object[] uriVariables) where T : class { AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(typeof(T), this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(this._messageConverters); @@ -336,7 +336,7 @@ namespace Spring.Http.Rest /// The URL. /// The dictionary containing variables for the URI template. /// The HTTP response message. - public HttpResponseMessage GetForMessage(string url, IDictionary uriVariables) where T : class + public HttpResponseMessage GetForMessage(string url, IDictionary uriVariables) where T : class { AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(typeof(T), this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(this._messageConverters); @@ -370,7 +370,7 @@ namespace Spring.Http.Rest /// The URL. /// The variables to expand the template. /// All HTTP headers of that resource - public HttpHeaders HeadForHeaders(string url, params string[] uriVariables) + public HttpHeaders HeadForHeaders(string url, params object[] uriVariables) { return this.Execute(url, HttpMethod.HEAD, null, this.headersExtractor, uriVariables); } @@ -384,7 +384,7 @@ namespace Spring.Http.Rest /// The URL. /// The dictionary containing variables for the URI template. /// All HTTP headers of that resource - public HttpHeaders HeadForHeaders(string url, IDictionary uriVariables) + public HttpHeaders HeadForHeaders(string url, IDictionary uriVariables) { return this.Execute(url, HttpMethod.HEAD, null, this.headersExtractor, uriVariables); } @@ -420,7 +420,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The variables to expand the template. /// The value for the Location header. - public Uri PostForLocation(string url, object request, params string[] uriVariables) + public Uri PostForLocation(string url, object request, params object[] uriVariables) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); HttpHeaders headers = this.Execute( @@ -445,7 +445,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The dictionary containing variables for the URI template. /// The value for the Location header. - public Uri PostForLocation(string url, object request, IDictionary uriVariables) + public Uri PostForLocation(string url, object request, IDictionary uriVariables) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); HttpHeaders headers = this.Execute( @@ -489,7 +489,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The variables to expand the template. /// The converted object. - public T PostForObject(string url, object request, params string[] uriVariables) where T : class + public T PostForObject(string url, object request, params object[] uriVariables) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, typeof(T), this._messageConverters); MessageConverterResponseExtractor responseExtractor = new MessageConverterResponseExtractor(this._messageConverters); @@ -513,7 +513,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The dictionary containing variables for the URI template. /// The converted object. - public T PostForObject(string url, object request, IDictionary uriVariables) where T : class + public T PostForObject(string url, object request, IDictionary uriVariables) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, typeof(T), this._messageConverters); MessageConverterResponseExtractor responseExtractor = new MessageConverterResponseExtractor(this._messageConverters); @@ -555,7 +555,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The variables to expand the template. /// The HTTP response message. - public HttpResponseMessage PostForMessage(string url, object request, params string[] uriVariables) where T : class + public HttpResponseMessage PostForMessage(string url, object request, params object[] uriVariables) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, typeof(T), this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(this._messageConverters); @@ -579,7 +579,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The dictionary containing variables for the URI template. /// The HTTP response message. - public HttpResponseMessage PostForMessage(string url, object request, IDictionary uriVariables) where T : class + public HttpResponseMessage PostForMessage(string url, object request, IDictionary uriVariables) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, typeof(T), this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(this._messageConverters); @@ -620,7 +620,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The variables to expand the template. /// The HTTP response message with no entity. - public HttpResponseMessage PostForMessage(string url, object request, params string[] uriVariables) + public HttpResponseMessage PostForMessage(string url, object request, params object[] uriVariables) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(); @@ -643,7 +643,7 @@ namespace Spring.Http.Rest /// The Object to be POSTed, may be null. /// The dictionary containing variables for the URI template. /// The HTTP response message with no entity. - public HttpResponseMessage PostForMessage(string url, object request, IDictionary uriVariables) + public HttpResponseMessage PostForMessage(string url, object request, IDictionary uriVariables) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(); @@ -685,7 +685,7 @@ namespace Spring.Http.Rest /// The URL. /// The Object to be PUT, may be null. /// The variables to expand the template. - public void Put(string url, object request, params string[] uriVariables) + public void Put(string url, object request, params object[] uriVariables) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); this.Execute(url, HttpMethod.PUT, requestCallback, null, uriVariables); @@ -705,7 +705,7 @@ namespace Spring.Http.Rest /// The URL. /// The Object to be PUT, may be null. /// The dictionary containing variables for the URI template. - public void Put(string url, object request, IDictionary uriVariables) + public void Put(string url, object request, IDictionary uriVariables) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); this.Execute(url, HttpMethod.PUT, requestCallback, null, uriVariables); @@ -737,7 +737,7 @@ namespace Spring.Http.Rest /// /// The URL. /// The variables to expand the template. - public void Delete(string url, params string[] uriVariables) + public void Delete(string url, params object[] uriVariables) { this.Execute(url, HttpMethod.DELETE, null, null, uriVariables); } @@ -750,7 +750,7 @@ namespace Spring.Http.Rest /// /// The URL. /// The dictionary containing variables for the URI template. - public void Delete(string url, IDictionary uriVariables) + public void Delete(string url, IDictionary uriVariables) { this.Execute(url, HttpMethod.DELETE, null, null, uriVariables); } @@ -777,7 +777,7 @@ namespace Spring.Http.Rest /// The URL. /// The variables to expand the template. /// The value of the allow header. - public IList OptionsForAllow(string url, params string[] uriVariables) + public IList OptionsForAllow(string url, params object[] uriVariables) { HttpHeaders headers = this.Execute( url, HttpMethod.OPTIONS, null, this.headersExtractor, uriVariables); @@ -793,7 +793,7 @@ namespace Spring.Http.Rest /// The URL. /// The dictionary containing variables for the URI template. /// The value of the allow header. - public IList OptionsForAllow(string url, IDictionary uriVariables) + public IList OptionsForAllow(string url, IDictionary uriVariables) { HttpHeaders headers = this.Execute( url, HttpMethod.OPTIONS, null, this.headersExtractor, uriVariables); @@ -832,7 +832,7 @@ namespace Spring.Http.Rest /// /// The variables to expand the template. /// The HTTP response message. - public HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, params string[] uriVariables) where T : class + public HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, params object[] uriVariables) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, typeof(T), this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(this._messageConverters); @@ -854,7 +854,7 @@ namespace Spring.Http.Rest /// /// The dictionary containing variables for the URI template. /// The HTTP response message. - public HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables) where T : class + public HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, typeof(T), this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(this._messageConverters); @@ -893,7 +893,7 @@ namespace Spring.Http.Rest /// /// The variables to expand the template. /// The HTTP response message with no entity. - public HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, params string[] uriVariables) + public HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, params object[] uriVariables) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(); @@ -914,7 +914,7 @@ namespace Spring.Http.Rest /// /// The dictionary containing variables for the URI template. /// The HTTP response message with no entity. - public HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables) + public HttpResponseMessage Exchange(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(); @@ -956,7 +956,7 @@ namespace Spring.Http.Rest /// Object that extracts the return value from the response. /// The variables to expand the template. /// An arbitrary object, as returned by the . - public T Execute(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, params string[] uriVariables) where T : class + public T Execute(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, params object[] uriVariables) where T : class { return this.DoExecute(this.BuildUri(this._baseAddress, url, uriVariables), method, requestCallback, responseExtractor); } @@ -975,7 +975,7 @@ namespace Spring.Http.Rest /// Object that extracts the return value from the response. /// The dictionary containing variables for the URI template. /// An arbitrary object, as returned by the . - public T Execute(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, IDictionary uriVariables) where T : class + public T Execute(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, IDictionary uriVariables) where T : class { return this.DoExecute(this.BuildUri(this._baseAddress, url, uriVariables), method, requestCallback, responseExtractor); } @@ -1004,14 +1004,14 @@ namespace Spring.Http.Rest #region GET - public void GetForObjectAsync(string url, string[] uriVariables, Action> getCompleted) where T : class + public void GetForObjectAsync(string url, object[] uriVariables, Action> getCompleted) where T : class { AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(typeof(T), this._messageConverters); MessageConverterResponseExtractor responseExtractor = new MessageConverterResponseExtractor(this._messageConverters); this.ExecuteAsync(url, HttpMethod.GET, requestCallback, responseExtractor, uriVariables, getCompleted); } - public void GetForObjectAsync(string url, IDictionary uriVariables, Action> getCompleted) where T : class + public void GetForObjectAsync(string url, IDictionary uriVariables, Action> getCompleted) where T : class { AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(typeof(T), this._messageConverters); MessageConverterResponseExtractor responseExtractor = new MessageConverterResponseExtractor(this._messageConverters); @@ -1025,14 +1025,14 @@ namespace Spring.Http.Rest this.ExecuteAsync(url, HttpMethod.GET, requestCallback, responseExtractor, getCompleted); } - public void GetForMessageAsync(string url, string[] uriVariables, Action>> getCompleted) where T : class + public void GetForMessageAsync(string url, object[] uriVariables, Action>> getCompleted) where T : class { AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(typeof(T), this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(this._messageConverters); this.ExecuteAsync>(url, HttpMethod.GET, requestCallback, responseExtractor, uriVariables, getCompleted); } - public void GetForMessageAsync(string url, IDictionary uriVariables, Action>> getCompleted) where T : class + public void GetForMessageAsync(string url, IDictionary uriVariables, Action>> getCompleted) where T : class { AcceptHeaderRequestCallback requestCallback = new AcceptHeaderRequestCallback(typeof(T), this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(this._messageConverters); @@ -1050,12 +1050,12 @@ namespace Spring.Http.Rest #region HEAD - public void HeadForHeadersAsync(string url, string[] uriVariables, Action> headCompleted) + public void HeadForHeadersAsync(string url, object[] uriVariables, Action> headCompleted) { this.ExecuteAsync(url, HttpMethod.HEAD, null, this.headersExtractor, uriVariables, headCompleted); } - public void HeadForHeadersAsync(string url, IDictionary uriVariables, Action> headCompleted) + public void HeadForHeadersAsync(string url, IDictionary uriVariables, Action> headCompleted) { this.ExecuteAsync(url, HttpMethod.HEAD, null, this.headersExtractor, uriVariables, headCompleted); } @@ -1069,7 +1069,7 @@ namespace Spring.Http.Rest #region POST - public void PostForLocationAsync(string url, object request, string[] uriVariables, Action postCompleted) + public void PostForLocationAsync(string url, object request, object[] uriVariables, Action postCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); this.ExecuteAsync(url, HttpMethod.POST, requestCallback, this.headersExtractor, uriVariables, @@ -1079,7 +1079,7 @@ namespace Spring.Http.Rest }); } - public void PostForLocationAsync(string url, object request, IDictionary uriVariables, Action postCompleted) + public void PostForLocationAsync(string url, object request, IDictionary uriVariables, Action postCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); this.ExecuteAsync(url, HttpMethod.POST, requestCallback, this.headersExtractor, uriVariables, @@ -1099,14 +1099,14 @@ namespace Spring.Http.Rest }); } - public void PostForObjectAsync(string url, object request, string[] uriVariables, Action> postCompleted) where T : class + public void PostForObjectAsync(string url, object request, object[] uriVariables, Action> postCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, typeof(T), this._messageConverters); MessageConverterResponseExtractor responseExtractor = new MessageConverterResponseExtractor(this._messageConverters); this.ExecuteAsync(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables, postCompleted); } - public void PostForObjectAsync(string url, object request, IDictionary uriVariables, Action> postCompleted) where T : class + public void PostForObjectAsync(string url, object request, IDictionary uriVariables, Action> postCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, typeof(T), this._messageConverters); MessageConverterResponseExtractor responseExtractor = new MessageConverterResponseExtractor(this._messageConverters); @@ -1120,14 +1120,14 @@ namespace Spring.Http.Rest this.ExecuteAsync(url, HttpMethod.POST, requestCallback, responseExtractor, postCompleted); } - public void PostForMessageAsync(string url, object request, string[] uriVariables, Action>> postCompleted) where T : class + public void PostForMessageAsync(string url, object request, object[] uriVariables, Action>> postCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, typeof(T), this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(this._messageConverters); this.ExecuteAsync>(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables, postCompleted); } - public void PostForMessageAsync(string url, object request, IDictionary uriVariables, Action>> postCompleted) where T : class + public void PostForMessageAsync(string url, object request, IDictionary uriVariables, Action>> postCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, typeof(T), this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(this._messageConverters); @@ -1141,14 +1141,14 @@ namespace Spring.Http.Rest this.ExecuteAsync>(url, HttpMethod.POST, requestCallback, responseExtractor, postCompleted); } - public void PostForMessageAsync(string url, object request, string[] uriVariables, Action> postCompleted) + public void PostForMessageAsync(string url, object request, object[] uriVariables, Action> postCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(); this.ExecuteAsync(url, HttpMethod.POST, requestCallback, responseExtractor, uriVariables, postCompleted); } - public void PostForMessageAsync(string url, object request, IDictionary uriVariables, Action> postCompleted) + public void PostForMessageAsync(string url, object request, IDictionary uriVariables, Action> postCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(); @@ -1166,13 +1166,13 @@ namespace Spring.Http.Rest #region PUT - public void PutAsync(string url, object request, string[] uriVariables, Action> putCompleted) + public void PutAsync(string url, object request, object[] uriVariables, Action> putCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); this.ExecuteAsync(url, HttpMethod.PUT, requestCallback, null, uriVariables, putCompleted); } - public void PutAsync(string url, object request, IDictionary uriVariables, Action> putCompleted) + public void PutAsync(string url, object request, IDictionary uriVariables, Action> putCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(request, this._messageConverters); this.ExecuteAsync(url, HttpMethod.PUT, requestCallback, null, uriVariables, putCompleted); @@ -1188,12 +1188,12 @@ namespace Spring.Http.Rest #region DELETE - public void DeleteAsync(string url, string[] uriVariables, Action> deleteCompleted) + public void DeleteAsync(string url, object[] uriVariables, Action> deleteCompleted) { this.ExecuteAsync(url, HttpMethod.DELETE, null, null, uriVariables, deleteCompleted); } - public void DeleteAsync(string url, IDictionary uriVariables, Action> deleteCompleted) + public void DeleteAsync(string url, IDictionary uriVariables, Action> deleteCompleted) { this.ExecuteAsync(url, HttpMethod.DELETE, null, null, uriVariables, deleteCompleted); } @@ -1207,7 +1207,7 @@ namespace Spring.Http.Rest #region OPTIONS - public void OptionsForAllowAsync(string url, string[] uriVariables, Action> optionsCompleted) + public void OptionsForAllowAsync(string url, object[] uriVariables, Action> optionsCompleted) { this.ExecuteAsync(url, HttpMethod.OPTIONS, null, this.headersExtractor, uriVariables, delegate(MethodCompletedEventArgs args) @@ -1216,7 +1216,7 @@ namespace Spring.Http.Rest }); } - public void OptionsForAllowAsync(string url, IDictionary uriVariables, Action> optionsCompleted) + public void OptionsForAllowAsync(string url, IDictionary uriVariables, Action> optionsCompleted) { this.ExecuteAsync(url, HttpMethod.OPTIONS, null, this.headersExtractor, uriVariables, delegate(MethodCompletedEventArgs args) @@ -1239,14 +1239,14 @@ namespace Spring.Http.Rest #region Exchange - public void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, string[] uriVariables, Action>> methodCompleted) where T : class + public void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, object[] uriVariables, Action>> methodCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, typeof(T), this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(this._messageConverters); this.ExecuteAsync>(url, method, requestCallback, responseExtractor, uriVariables, methodCompleted); } - public void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables, Action>> methodCompleted) where T : class + public void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables, Action>> methodCompleted) where T : class { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, typeof(T), this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(this._messageConverters); @@ -1260,14 +1260,14 @@ namespace Spring.Http.Rest this.ExecuteAsync>(url, method, requestCallback, responseExtractor, methodCompleted); } - public void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, string[] uriVariables, Action> methodCompleted) + public void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, object[] uriVariables, Action> methodCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(); this.ExecuteAsync(url, method, requestCallback, responseExtractor, uriVariables, methodCompleted); } - public void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables, Action> methodCompleted) + public void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, IDictionary uriVariables, Action> methodCompleted) { HttpEntityRequestCallback requestCallback = new HttpEntityRequestCallback(requestEntity, this._messageConverters); HttpMessageResponseExtractor responseExtractor = new HttpMessageResponseExtractor(); @@ -1285,13 +1285,13 @@ namespace Spring.Http.Rest #region General execution - public void ExecuteAsync(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, string[] uriVariables, Action> methodCompleted) where T : class + public void ExecuteAsync(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, object[] uriVariables, Action> methodCompleted) where T : class { this.DoExecuteAsync(BuildUri(this._baseAddress, url, uriVariables), method, requestCallback, responseExtractor, methodCompleted); } - public void ExecuteAsync(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, IDictionary uriVariables, Action> methodCompleted) where T : class + public void ExecuteAsync(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor responseExtractor, IDictionary uriVariables, Action> methodCompleted) where T : class { this.DoExecuteAsync(BuildUri(this._baseAddress, url, uriVariables), method, requestCallback, responseExtractor, methodCompleted); @@ -1448,14 +1448,14 @@ namespace Spring.Http.Rest // - UriTemplate.BindByPosition is not supported in Silverlight // - UriTemplate class is not included in the Silverlight core dlls - protected virtual Uri BuildUri(Uri baseAddress, string url, string[] uriVariables) + protected virtual Uri BuildUri(Uri baseAddress, string url, object[] uriVariables) { UriTemplate uriTemplate = new UriTemplate(url); Uri uri = uriTemplate.Expand(uriVariables); return BuildUri(baseAddress, uri); } - protected virtual Uri BuildUri(Uri baseAddress, string url, IDictionary uriVariables) + protected virtual Uri BuildUri(Uri baseAddress, string url, IDictionary uriVariables) { UriTemplate uriTemplate = new UriTemplate(url); Uri uri = uriTemplate.Expand(uriVariables); diff --git a/src/Spring/Spring.Http/Util/UriTemplate.cs b/src/Spring/Spring.Http/Util/UriTemplate.cs index 7f2caf57..52f89711 100644 --- a/src/Spring/Spring.Http/Util/UriTemplate.cs +++ b/src/Spring/Spring.Http/Util/UriTemplate.cs @@ -79,16 +79,16 @@ namespace Spring.Util /// /// /// UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}"); - /// IDictionary<string, string> uriVariables = new Dictionary<String, String>(); + /// IDictionary<string, object> uriVariables = new Dictionary<string, object>(); /// uriVariables.Add("booking", "42"); - /// uriVariables.Add("hotel", "1"); + /// uriVariables.Add("hotel", 1); /// Console.Out.WriteLine(template.Expand(uriVariables)); /// /// will print:
http://example.com/hotels/1/bookings/42
///
/// The dictionary of URI variables. /// The expanded URI - public Uri Expand(IDictionary uriVariables) + public Uri Expand(IDictionary uriVariables) { if (uriVariables.Count != this.variableNames.Length) { @@ -119,13 +119,13 @@ namespace Spring.Util /// /// /// UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}"); - /// Console.Out.WriteLine(template.Expand("1", "42")); + /// Console.Out.WriteLine(template.Expand(1, "42")); /// /// will print:
http://example.com/hotels/1/bookings/42
///
/// The array of URI variables. /// The expanded URI - public Uri Expand(params string[] uriVariableValues) + public Uri Expand(params object[] uriVariableValues) { if (uriVariableValues.Length != this.variableNames.Length) { @@ -194,10 +194,10 @@ namespace Spring.Util return this.uriTemplate; } - private static string Replace(string uriTemplate, string token, string value) + private static string Replace(string uriTemplate, string token, object value) { string quotedToken = BRACE_LEFT + token + BRACE_RIGHT; - return uriTemplate.Replace(quotedToken, value); + return uriTemplate.Replace(quotedToken, (value == null) ? String.Empty : value.ToString()); } // Static inner class to parse uri template strings into a matching regular expression. diff --git a/test/Spring/Spring.Http.Tests/Http/Rest/RestTemplateIntegrationTests.cs b/test/Spring/Spring.Http.Tests/Http/Rest/RestTemplateIntegrationTests.cs index a5245ed4..3d6c7aa9 100644 --- a/test/Spring/Spring.Http.Tests/Http/Rest/RestTemplateIntegrationTests.cs +++ b/test/Spring/Spring.Http.Tests/Http/Rest/RestTemplateIntegrationTests.cs @@ -77,15 +77,15 @@ namespace Spring.Http.Rest [Test] public void GetStringVarArgsTemplateVariables() { - string result = template.GetForObject("user/{id}", "1"); + string result = template.GetForObject("user/{id}", 1); Assert.AreEqual("Bruno Baïa", result, "Invalid content"); } [Test] public void GetStringDictionaryTemplateVariables() { - IDictionary uriVariables = new Dictionary(1); - uriVariables.Add("id", "2"); + IDictionary uriVariables = new Dictionary(1); + uriVariables.Add("id", 2); string result = template.GetForObject("user/{id}", uriVariables); Assert.AreEqual("Marie Baia", result, "Invalid content"); } @@ -95,13 +95,13 @@ namespace Spring.Http.Rest ExpectedMessage = "The server returned 'User with id '5' not found' with the status code 404 - NotFound.")] public void GetStringError() { - string result = template.GetForObject("user/{id}", "5"); + string result = template.GetForObject("user/{id}", 5); } [Test] public void GetStringForMessage() { - HttpResponseMessage result = template.GetForMessage("user/{id}", "1"); + HttpResponseMessage result = template.GetForMessage("user/{id}", 1); Assert.AreEqual("Bruno Baïa", result.Body, "Invalid content"); Assert.AreEqual(contentType, result.Headers.ContentType, "Invalid content-type"); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode, "Invalid status code"); diff --git a/test/Spring/Spring.Http.Tests/Util/UriTemplateTests.cs b/test/Spring/Spring.Http.Tests/Util/UriTemplateTests.cs index a91a2270..d673a5bc 100644 --- a/test/Spring/Spring.Http.Tests/Util/UriTemplateTests.cs +++ b/test/Spring/Spring.Http.Tests/Util/UriTemplateTests.cs @@ -60,8 +60,8 @@ namespace Spring.Util public void MultipleExpandVarArgs() { UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}"); - Uri result = template.Expand("2", "21"); - result = template.Expand("1", "42"); + Uri result = template.Expand("2", 21); + result = template.Expand(1, "42"); Assert.AreEqual(new Uri("http://example.com/hotels/1/bookings/42"), result, "Invalid expanded template"); } @@ -72,7 +72,7 @@ namespace Spring.Util public void ExpandVarArgsInvalidAmountVariables() { UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}"); - template.Expand("1", "42", "100"); + template.Expand("1", "42", 100); } [Test] @@ -87,9 +87,9 @@ namespace Spring.Util [Test] public void ExpandDictionary() { - IDictionary uriVariables = new Dictionary(2); + IDictionary uriVariables = new Dictionary(2); uriVariables.Add("booking", "42"); - uriVariables.Add("hotel", "1"); + uriVariables.Add("hotel", 1); // absolute UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}"); @@ -107,12 +107,12 @@ namespace Spring.Util { UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}"); - IDictionary uriVariables = new Dictionary(2); - uriVariables.Add("booking", "21"); + IDictionary uriVariables = new Dictionary(2); + uriVariables.Add("booking", 21); uriVariables.Add("hotel", "2"); Uri result = template.Expand(uriVariables); - uriVariables = new Dictionary(2); + uriVariables = new Dictionary(2); uriVariables.Add("booking", "42"); uriVariables.Add("hotel", "1"); result = template.Expand(uriVariables); @@ -126,8 +126,8 @@ namespace Spring.Util ExpectedMessage = "Invalid amount of variables values in 'http://example.com/hotels/{hotel}/bookings/{booking}': expected 2; got 1")] public void ExpandDictionaryInvalidAmountVariables() { - IDictionary uriVariables = new Dictionary(2); - uriVariables.Add("hotel", "1"); + IDictionary uriVariables = new Dictionary(2); + uriVariables.Add("hotel", 1); UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}"); template.Expand(uriVariables); @@ -139,9 +139,9 @@ namespace Spring.Util ExpectedMessage = "'uriVariables' dictionary has no value for 'hotel'")] public void ExpandDictionaryUnboundVariables() { - IDictionary uriVariables = new Dictionary(2); + IDictionary uriVariables = new Dictionary(2); uriVariables.Add("booking", "42"); - uriVariables.Add("bar", "1"); + uriVariables.Add("bar", 1); UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}"); template.Expand(uriVariables);