REST client API: Code comments (SPRNET-1345)

This commit is contained in:
bbaia
2011-01-06 18:13:50 +00:00
parent ff72c62226
commit 2d9b773f29
14 changed files with 1096 additions and 321 deletions

View File

@@ -2,4 +2,4 @@ using System;
using System.Reflection;
[assembly: AssemblyTitle("Spring.Http")]
[assembly: AssemblyDescription("Interfaces and classes that provide REST client API in Spring.Net")]
[assembly: AssemblyDescription("Interfaces and classes that provide REST client API in Spring.NET")]

View File

@@ -25,30 +25,57 @@ using System.Collections.Generic;
namespace Spring.Collections.Specialized
{
/// <summary>
/// Represents a collection of associated string keys and multiple string values.
/// </summary>
/// <remarks>
/// Silverlight's implementation, based on a dictionary, of the .NET Framework NameValueCollection class.
/// </remarks>
/// <author>Bruno Baia</author>
public class NameValueCollection : IEnumerable<string>
{
private Dictionary<string, List<string>> innerCollection;
/// <summary>
/// Creates a new instance of the <see cref="NameValueCollection"/> class.
/// </summary>
public NameValueCollection()
{
innerCollection = new Dictionary<string, List<string>>();
}
/// <summary>
/// Creates a new instance of the <see cref="NameValueCollection"/> class
/// with the specified initial capacity.
/// </summary>
public NameValueCollection(int capacity)
{
innerCollection = new Dictionary<string, List<string>>(capacity);
}
/// <summary>
/// Creates a new instance of the <see cref="NameValueCollection"/> class
/// with the specified comparer.
/// </summary>
public NameValueCollection(IEqualityComparer<string> comparer)
{
innerCollection = new Dictionary<string, List<string>>(comparer);
}
/// <summary>
/// Creates a new instance of the <see cref="NameValueCollection"/> class
/// with the specified initial capacity and comparer.
/// </summary>
public NameValueCollection(int capacity, IEqualityComparer<string> comparer)
{
innerCollection = new Dictionary<string, List<string>>(capacity, comparer);
}
/// <summary>
/// Adds the given single value to the current list of values for the given key.
/// </summary>
/// <param name="name">The key to use.</param>
/// <param name="value">The value to add.</param>
public virtual void Add(string name, string value)
{
List<string> list;
@@ -60,6 +87,11 @@ namespace Spring.Collections.Specialized
this.innerCollection[name] = list;
}
/// <summary>
/// Returns values for the given key as a comma-delimited string.
/// </summary>
/// <param name="name">The key that contains the values to get.</param>
/// <returns>A comma-delimited string, if found; otherwise <see langword="null"/>.</returns>
public virtual string Get(string name)
{
string str = null;
@@ -85,6 +117,11 @@ namespace Spring.Collections.Specialized
return str;
}
/// <summary>
/// Returns values for the given key as a string array.
/// </summary>
/// <param name="name">The key that contains the values to get.</param>
/// <returns>A string array, if found; otherwise, <see langword="null"/>.</returns>
public virtual string[] GetValues(string name)
{
List<string> list;
@@ -95,18 +132,34 @@ namespace Spring.Collections.Specialized
return null;
}
public virtual void Set(string key, string value)
/// <summary>
/// Sets the given single value under the given key.
/// </summary>
/// <param name="name">The key to use.</param>
/// <param name="value">The value to set.</param>
public virtual void Set(string name, string value)
{
List<string> list = new List<string>();
list.Add(value);
this.innerCollection[key] = list;
this.innerCollection[name] = list;
}
public virtual bool Remove(string key)
/// <summary>
/// Removes the given key from the collection.
/// </summary>
/// <param name="name">The key to remove.</param>
/// <returns>
/// <see langword="true"/> if the key have been found and removed from the collection;
/// otherwise, <see langword="false"/>.
/// </returns>
public virtual bool Remove(string name)
{
return this.innerCollection.Remove(key);
return this.innerCollection.Remove(name);
}
/// <summary>
/// Gets all the keys in the collection.
/// </summary>
public virtual string[] AllKeys
{
get
@@ -118,6 +171,9 @@ namespace Spring.Collections.Specialized
}
}
/// <summary>
/// Gets the number of keys contained in the collection.
/// </summary>
public virtual int Count
{
get
@@ -126,6 +182,11 @@ namespace Spring.Collections.Specialized
}
}
/// <summary>
/// Gets values as a comma-delimited string or sets a single value for the given key.
/// </summary>
/// <param name="name">The key to use.</param>
/// <returns>A comma-delimited string, if found; otherwise <see langword="null"/>.</returns>
public virtual string this[string name]
{
get

View File

@@ -23,24 +23,40 @@ using System.ComponentModel;
namespace Spring.Http.Client
{
// TODO: Rename this to HttpRequestCompletedEventArgs or something ?
/// <summary>
/// Provides data when an asynchronous HTTP request execution completes.
/// </summary>
/// <see cref="IClientHttpRequest"/>
public class ExecuteCompletedEventArgs : AsyncCompletedEventArgs
{
private IClientHttpResponse response;
/// <summary>
/// Gets the <see cref="IClientHttpResponse">response</see> result of the execution.
/// </summary>
/// <exception cref="System.InvalidOperationException">If the execution was canceled.</exception>
/// <exception cref="System.Reflection.TargetInvocationException">If the execution failed.</exception>
public IClientHttpResponse Response
{
get
{
// Raise an exception if the operation failed or
// was canceled.
// Raise an exception if the operation failed or was canceled.
base.RaiseExceptionIfNecessary();
// If the operation was successful, return the
// property value.
// If the operation was successful, return the value.
return response;
}
}
/// <summary>
/// Creates a new instance of <see cref="ExecuteCompletedEventArgs"/>.
/// </summary>
/// <param name="response">The response of the execution.</param>
/// <param name="exception">Any error that occurred during the asynchronous execution.</param>
/// <param name="cancelled">A value indicating whether the asynchronous execution was canceled.</param>
/// <param name="userState">The optional user-supplied state object.</param>
public ExecuteCompletedEventArgs(IClientHttpResponse response, Exception exception, bool cancelled, object userState)
: base(exception, cancelled, userState)
{

View File

@@ -59,8 +59,21 @@ namespace Spring.Http.Client
IClientHttpResponse Execute();
#endif
/// <summary>
/// Execute this request asynchronously.
/// </summary>
/// <param name="state">
/// An optional user-defined object that is passed to the method invoked
/// when the asynchronous operation completes.
/// </param>
/// <param name="executeCompleted">
/// The <see cref="Action{ExecuteCompletedEventArgs}"/> to perform when the asynchronous execution completes.
/// </param>
void ExecuteAsync(object state, Action<ExecuteCompletedEventArgs> executeCompleted);
/// <summary>
/// Cancels a pending asynchronous operation.
/// </summary>
void CancelAsync();
}
}

View File

@@ -45,7 +45,7 @@ namespace Spring.Http.Client
private bool isCancelled;
/// <summary>
/// Gets the <see cref="HttpWebRequest"/> instance used.
/// Gets the <see cref="HttpWebRequest"/> instance used by the request.
/// </summary>
public HttpWebRequest HttpWebRequest
{
@@ -111,6 +111,7 @@ namespace Spring.Http.Client
/// Execute this request, resulting in a <see cref="IClientHttpResponse" /> that can be read.
/// </summary>
/// <returns>The response result of the execution</returns>
/// <see cref="InvalidOperationException">If the request is already executed or is currently executing.</see>
public IClientHttpResponse Execute()
{
this.EnsureNotExecuted();
@@ -118,7 +119,7 @@ namespace Spring.Http.Client
try
{
// Prepare
this.PrepareRequest();
this.PrepareForExecution();
// Write
if (this.body != null)
@@ -133,7 +134,7 @@ namespace Spring.Http.Client
HttpWebResponse httpWebResponse = this.httpWebRequest.GetResponse() as HttpWebResponse;
if (this.httpWebRequest.HaveResponse && httpWebResponse != null)
{
return new WebClientHttpResponse(httpWebResponse);
return this.CreateClientHttpResponse(httpWebResponse);
}
}
catch (WebException ex)
@@ -144,7 +145,7 @@ namespace Spring.Http.Client
if (httpWebResponse != null)
{
this.isExecuted = true;
return new WebClientHttpResponse(httpWebResponse);
return this.CreateClientHttpResponse(httpWebResponse);
}
throw;
}
@@ -153,6 +154,17 @@ namespace Spring.Http.Client
}
#endif
/// <summary>
/// Execute this request asynchronously.
/// </summary>
/// <param name="state">
/// An optional user-defined object that is passed to the method invoked
/// when the asynchronous operation completes.
/// </param>
/// <param name="executeCompleted">
/// The <see cref="Action{ExecuteCompletedEventArgs}"/> to perform when the asynchronous execution completes.
/// </param>
/// <see cref="InvalidOperationException">If the request is already executed or is currently executing.</see>
public void ExecuteAsync(object state, Action<ExecuteCompletedEventArgs> executeCompleted)
{
this.EnsureNotExecuted();
@@ -163,7 +175,7 @@ namespace Spring.Http.Client
try
{
// Prepare
this.PrepareRequest();
this.PrepareForExecution();
// Post request
if (this.body != null)
@@ -190,6 +202,9 @@ namespace Spring.Http.Client
}
}
/// <summary>
/// Cancels a pending asynchronous operation.
/// </summary>
public void CancelAsync()
{
this.isCancelled = true;
@@ -249,7 +264,7 @@ namespace Spring.Http.Client
HttpWebResponse httpWebResponse = this.httpWebRequest.EndGetResponse(result) as HttpWebResponse;
if (this.httpWebRequest.HaveResponse == true && httpWebResponse != null)
{
response = new WebClientHttpResponse(httpWebResponse);
response = this.CreateClientHttpResponse(httpWebResponse);
}
}
catch (Exception ex)
@@ -267,7 +282,7 @@ namespace Spring.Http.Client
if (httpWebResponse != null)
{
exception = null;
response = new WebClientHttpResponse(httpWebResponse);
response = this.CreateClientHttpResponse(httpWebResponse);
}
}
}
@@ -326,6 +341,10 @@ namespace Spring.Http.Client
#endregion
/// <summary>
/// Ensures that the request can be executed.
/// </summary>
/// <see cref="InvalidOperationException">If the request is already executed or is currently executing.</see>
protected void EnsureNotExecuted()
{
if (this.isExecuted)
@@ -334,13 +353,26 @@ namespace Spring.Http.Client
}
}
/// <summary>
/// Creates and returns an <see cref="IClientHttpResponse"/> implementation associated
/// with the request.
/// </summary>
/// <param name="response">The <see cref="HttpWebResponse"/> instance to use.</param>
/// <returns>
/// An <see cref="IClientHttpResponse"/> implementation associated with the request.
/// </returns>
protected virtual IClientHttpResponse CreateClientHttpResponse(HttpWebResponse response)
{
return new WebClientHttpResponse(response);
}
/// <summary>
/// Prepare the request for execution.
/// </summary>
/// <remarks>
/// Default implementation copies headers to the request. Can be overridden in subclasses.
/// Default implementation copies headers to the .NET request. Can be overridden in subclasses.
/// </remarks>
protected virtual void PrepareRequest()
protected virtual void PrepareForExecution()
{
// Copy headers
foreach (string header in this.headers)

View File

@@ -102,6 +102,13 @@ namespace Spring.Http.Client
#if SILVERLIGHT && !WINDOWS_PHONE
private WebRequestCreatorType _webRequestCreator;
/// <summary>
/// Gets or sets a value that indicates how HTTP requests and responses will be handled.
/// </summary>
/// <remarks>
/// By default, this factory will use the default Silverlight behavior for HTTP methods GET and POST,
/// and force the client HTTP stack for other HTTP methods.
/// </remarks>
public WebRequestCreatorType WebRequestCreator
{
get { return this._webRequestCreator; }
@@ -127,7 +134,7 @@ namespace Spring.Http.Client
public WebClientHttpRequestFactory()
{
#if SILVERLIGHT && !WINDOWS_PHONE
this._webRequestCreator = WebRequestCreatorType.Default;
this._webRequestCreator = WebRequestCreatorType.Unknown;
#endif
}
@@ -150,7 +157,7 @@ namespace Spring.Http.Client
case WebRequestCreatorType.BrowserHttp:
this.httpWebRequest = (HttpWebRequest)System.Net.Browser.WebRequestCreator.BrowserHttp.Create(uri);
break;
case WebRequestCreatorType.Default:
case WebRequestCreatorType.Unknown:
if (method == HttpMethod.GET || method == HttpMethod.POST)
{
this.httpWebRequest = WebRequest.Create(uri) as HttpWebRequest;
@@ -203,10 +210,22 @@ namespace Spring.Http.Client
}
#if SILVERLIGHT && !WINDOWS_PHONE
/// <summary>
/// Defines identifiers for supported Silverlight HTTP handling stacks.
/// </summary>
public enum WebRequestCreatorType
{
Default,
/// <summary>
/// Specifies an unknown HTTP handling stack.
/// </summary>
Unknown,
/// <summary>
/// Specifies browser HTTP handling stack.
/// </summary>
BrowserHttp,
/// <summary>
/// Specifies client HTTP handling stack.
/// </summary>
ClientHttp
}
#endif

View File

@@ -37,7 +37,7 @@ namespace Spring.Http.Client
private HttpWebResponse httpWebResponse;
/// <summary>
/// Gets the <see cref="HttpWebResponse"/> instance used.
/// Gets the <see cref="HttpWebResponse"/> instance used by the response.
/// </summary>
public HttpWebResponse HttpWebResponse
{
@@ -56,39 +56,7 @@ namespace Spring.Http.Client
this.httpWebResponse = response;
this.headers = new HttpHeaders();
#if NET_2_0 || WINDOWS_PHONE
foreach (string header in this.httpWebResponse.Headers)
{
this.headers[header] = this.httpWebResponse.Headers[header];
}
#endif
#if SILVERLIGHT_3
try
{
foreach (string header in this.httpWebResponse.Headers)
{
this.headers[header] = this.httpWebResponse.Headers[header];
}
}
catch(NotImplementedException)
{
this.headers.ContentLength = this.httpWebResponse.ContentLength;
this.headers["Content-Type"] = this.httpWebResponse.ContentType;
}
#elif SILVERLIGHT
if (this.httpWebResponse.SupportsHeaders)
{
foreach (string header in this.httpWebResponse.Headers)
{
this.headers[header] = this.httpWebResponse.Headers[header];
}
}
else
{
this.headers.ContentLength = this.httpWebResponse.ContentLength;
this.headers["Content-Type"] = this.httpWebResponse.ContentType;
}
#endif
this.Initialize();
}
#region IClientHttpResponse Membres
@@ -148,5 +116,48 @@ namespace Spring.Http.Client
}
#endregion
/// <summary>
/// Initialize the response.
/// </summary>
/// <remarks>
/// Default implementation copies headers from the .NET response. Can be overridden in subclasses.
/// </remarks>
protected virtual void Initialize()
{
#if NET_2_0 || WINDOWS_PHONE
foreach (string header in this.httpWebResponse.Headers)
{
this.headers[header] = this.httpWebResponse.Headers[header];
}
#endif
#if SILVERLIGHT_3
try
{
foreach (string header in this.httpWebResponse.Headers)
{
this.headers[header] = this.httpWebResponse.Headers[header];
}
}
catch(NotImplementedException)
{
this.headers.ContentLength = this.httpWebResponse.ContentLength;
this.headers["Content-Type"] = this.httpWebResponse.ContentType;
}
#elif SILVERLIGHT
if (this.httpWebResponse.SupportsHeaders)
{
foreach (string header in this.httpWebResponse.Headers)
{
this.headers[header] = this.httpWebResponse.Headers[header];
}
}
else
{
this.headers.ContentLength = this.httpWebResponse.ContentLength;
this.headers["Content-Type"] = this.httpWebResponse.ContentType;
}
#endif
}
}
}

View File

@@ -25,23 +25,23 @@ using System.Collections.Generic;
namespace Spring.Http.Rest
{
/// <summary>
/// Interface specifying a basic set of RESTful operations.
/// Interface specifying a basic set of RESTful asynchrone operations.
/// </summary>
/// <remarks>
/// Not often used directly, but a useful option to enhance testability,
/// as it can easily be mocked or stubbed.
/// </remarks>
/// <see cref="RestTemplate"/>
/// <author>Bruno Baia (.NET)</author>
/// <author>Arjen Poutsma</author>
/// <author>Juergen Hoeller</author>
/// <author>Bruno Baia (.NET)</author>
public interface IRestAsyncOperations
{
#region GET
/// <summary>
/// Retrieve a representation by doing a GET on the specified URL.
/// The response (if any) is converted and returned.
/// Asynchronously retrieve a representation by doing a GET on the specified URL.
/// The response (if any) is converted.
/// </summary>
/// <remarks>
/// URI Template variables are expanded using the given URI variables, if any.
@@ -49,12 +49,14 @@ namespace Spring.Http.Rest
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>The converted object</returns>
/// <param name="getCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous GET method completes.
/// </param>
void GetForObjectAsync<T>(string url, object[] uriVariables, Action<MethodCompletedEventArgs<T>> getCompleted) where T : class;
/// <summary>
/// Retrieve a representation by doing a GET on the specified URL.
/// The response (if any) is converted and returned.
/// Asynchronously retrieve a representation by doing a GET on the specified URL.
/// The response (if any) is converted.
/// </summary>
/// <remarks>
/// URI Template variables are expanded using the given dictionary.
@@ -62,20 +64,24 @@ namespace Spring.Http.Rest
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>The converted object</returns>
/// <param name="getCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous GET method completes.
/// </param>
void GetForObjectAsync<T>(string url, IDictionary<string, object> uriVariables, Action<MethodCompletedEventArgs<T>> getCompleted) where T : class;
/// <summary>
/// Retrieve a representation by doing a GET on the specified URL.
/// The response (if any) is converted and returned.
/// Asynchronously retrieve a representation by doing a GET on the specified URL.
/// The response (if any) is converted.
/// </summary>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <returns>The converted object</returns>
/// <param name="getCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous GET method completes.
/// </param>
void GetForObjectAsync<T>(Uri url, Action<MethodCompletedEventArgs<T>> getCompleted) where T : class;
/// <summary>
/// Retrieve an entity by doing a GET on the specified URL.
/// Asynchronously retrieve an entity by doing a GET on the specified URL.
/// The response is converted and stored in an <see cref="HttpResponseMessage{T}"/>.
/// </summary>
/// <remarks>
@@ -84,11 +90,13 @@ namespace Spring.Http.Rest
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>The HTTP response message.</returns>
/// <param name="getCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous GET method completes.
/// </param>
void GetForMessageAsync<T>(string url, object[] uriVariables, Action<MethodCompletedEventArgs<HttpResponseMessage<T>>> getCompleted) where T : class;
/// <summary>
/// Retrieve an entity by doing a GET on the specified URL.
/// Asynchronously retrieve an entity by doing a GET on the specified URL.
/// The response is converted and stored in an <see cref="HttpResponseMessage{T}"/>.
/// </summary>
/// <remarks>
@@ -97,16 +105,20 @@ namespace Spring.Http.Rest
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>The HTTP response message.</returns>
/// <param name="getCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous GET method completes.
/// </param>
void GetForMessageAsync<T>(string url, IDictionary<string, object> uriVariables, Action<MethodCompletedEventArgs<HttpResponseMessage<T>>> getCompleted) where T : class;
/// <summary>
/// Retrieve an entity by doing a GET on the specified URL.
/// Asynchronously retrieve an entity by doing a GET on the specified URL.
/// The response is converted and stored in an <see cref="HttpResponseMessage{T}"/>.
/// </summary>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <returns>The HTTP response message.</returns>
/// <param name="getCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous GET method completes.
/// </param>
void GetForMessageAsync<T>(Uri url, Action<MethodCompletedEventArgs<HttpResponseMessage<T>>> getCompleted) where T : class;
#endregion
@@ -114,32 +126,38 @@ namespace Spring.Http.Rest
#region HEAD
/// <summary>
/// Retrieve all headers of the resource specified by the URI template.
/// Asynchronously retrieve all headers of the resource specified by the URI template.
/// </summary>
/// <remarks>
/// URI Template variables are expanded using the given URI variables, if any.
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>All HTTP headers of that resource</returns>
/// <param name="headCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous HEAD method completes.
/// </param>
void HeadForHeadersAsync(string url, object[] uriVariables, Action<MethodCompletedEventArgs<HttpHeaders>> headCompleted);
/// <summary>
/// Retrieve all headers of the resource specified by the URI template.
/// Asynchronously retrieve all headers of the resource specified by the URI template.
/// </summary>
/// <remarks>
/// URI Template variables are expanded using the given dictionary.
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>All HTTP headers of that resource</returns>
/// <param name="headCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous HEAD method completes.
/// </param>
void HeadForHeadersAsync(string url, IDictionary<string, object> uriVariables, Action<MethodCompletedEventArgs<HttpHeaders>> headCompleted);
/// <summary>
/// Retrieve all headers of the resource specified by the URI template.
/// Asynchronously retrieve all headers of the resource specified by the URI template.
/// </summary>
/// <param name="url">The URL.</param>
/// <returns>All HTTP headers of that resource</returns>
/// <param name="headCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous HEAD method completes.
/// </param>
void HeadForHeadersAsync(Uri url, Action<MethodCompletedEventArgs<HttpHeaders>> headCompleted);
#endregion
@@ -147,7 +165,7 @@ namespace Spring.Http.Rest
#region POST
/// <summary>
/// Create a new resource by POSTing the given object to the URI template,
/// Asynchronously create a new resource by POSTing the given object to the URI template,
/// and returns the value of the 'Location' header.
/// This header typically indicates where the new resource is stored.
/// </summary>
@@ -155,18 +173,19 @@ namespace Spring.Http.Rest
/// <para>
/// URI Template variables are expanded using the given URI variables, if any.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>The value for the Location header.</returns>
/// <param name="postCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous POST method completes.
/// </param>
void PostForLocationAsync(string url, object request, object[] uriVariables, Action<Uri> postCompleted);
/// <summary>
/// Create a new resource by POSTing the given object to the URI template,
/// Asynchronously create a new resource by POSTing the given object to the URI template,
/// and returns the value of the 'Location' header.
/// This header typically indicates where the new resource is stored.
/// </summary>
@@ -174,177 +193,188 @@ namespace Spring.Http.Rest
/// <para>
/// URI Template variables are expanded using the given dictionary.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>The value for the Location header.</returns>
/// <param name="postCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous POST method completes.
/// </param>
void PostForLocationAsync(string url, object request, IDictionary<string, object> uriVariables, Action<Uri> postCompleted);
/// <summary>
/// Create a new resource by POSTing the given object to the URI template,
/// Asynchronously create a new resource by POSTing the given object to the URI template,
/// and returns the value of the 'Location' header.
/// This header typically indicates where the new resource is stored.
/// </summary>
/// <remarks>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <returns>The value for the Location header.</returns>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="postCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous POST method completes.
/// </param>
void PostForLocationAsync(Uri url, object request, Action<Uri> postCompleted);
/// <summary>
/// Create a new resource by POSTing the given object to the URI template,
/// Asynchronously create a new resource by POSTing the given object to the URI template,
/// and returns the representation found in the response.
/// </summary>
/// <remarks>
/// <para>
/// URI Template variables are expanded using the given URI variables, if any.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>The converted object.</returns>
/// <param name="postCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous POST method completes.
/// </param>
void PostForObjectAsync<T>(string url, object request, object[] uriVariables, Action<MethodCompletedEventArgs<T>> postCompleted) where T : class;
/// <summary>
/// Create a new resource by POSTing the given object to the URI template,
/// Asynchronously create a new resource by POSTing the given object to the URI template,
/// and returns the representation found in the response.
/// </summary>
/// <remarks>
/// <para>
/// URI Template variables are expanded using the given dictionary.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>The converted object.</returns>
/// <param name="postCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous POST method completes.
/// </param>
void PostForObjectAsync<T>(string url, object request, IDictionary<string, object> uriVariables, Action<MethodCompletedEventArgs<T>> postCompleted) where T : class;
/// <summary>
/// Create a new resource by POSTing the given object to the URI template,
/// Asynchronously create a new resource by POSTing the given object to the URI template,
/// and returns the representation found in the response.
/// </summary>
/// <remarks>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </remarks>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <returns>The converted object.</returns>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="postCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous POST method completes.
/// </param>
void PostForObjectAsync<T>(Uri url, object request, Action<MethodCompletedEventArgs<T>> postCompleted) where T : class;
/// <summary>
/// Create a new resource by POSTing the given object to the URI template,
/// Asynchronously create a new resource by POSTing the given object to the URI template,
/// and returns the response as <see cref="HttpResponseMessage{T}"/>.
/// </summary>
/// <remarks>
/// <para>
/// URI Template variables are expanded using the given URI variables, if any.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>The HTTP response message.</returns>
/// <param name="postCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous POST method completes.
/// </param>
void PostForMessageAsync<T>(string url, object request, object[] uriVariables, Action<MethodCompletedEventArgs<HttpResponseMessage<T>>> postCompleted) where T : class;
/// <summary>
/// Create a new resource by POSTing the given object to the URI template,
/// Asynchronously create a new resource by POSTing the given object to the URI template,
/// and returns the response as <see cref="HttpResponseMessage{T}"/>.
/// </summary>
/// <remarks>
/// <para>
/// URI Template variables are expanded using the given dictionary.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>The HTTP response message.</returns>
/// <param name="postCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous POST method completes.
/// </param>
void PostForMessageAsync<T>(string url, object request, IDictionary<string, object> uriVariables, Action<MethodCompletedEventArgs<HttpResponseMessage<T>>> postCompleted) where T : class;
/// <summary>
/// Create a new resource by POSTing the given object to the URI template,
/// Asynchronously create a new resource by POSTing the given object to the URI template,
/// and returns the response as <see cref="HttpResponseMessage{T}"/>.
/// </summary>
/// <remarks>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </remarks>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <returns>The HTTP response message.</returns>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="postCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous POST method completes.
/// </param>
void PostForMessageAsync<T>(Uri url, object request, Action<MethodCompletedEventArgs<HttpResponseMessage<T>>> postCompleted) where T : class;
/// <summary>
/// Create a new resource by POSTing the given object to the URI template,
/// Asynchronously create a new resource by POSTing the given object to the URI template,
/// and returns the response with no entity as <see cref="HttpResponseMessage"/>.
/// </summary>
/// <remarks>
/// <para>
/// URI Template variables are expanded using the given URI variables, if any.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>The HTTP response message with no entity.</returns>
/// <param name="postCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous POST method completes.
/// </param>
void PostForMessageAsync(string url, object request, object[] uriVariables, Action<MethodCompletedEventArgs<HttpResponseMessage>> postCompleted);
/// <summary>
/// Create a new resource by POSTing the given object to the URI template,
/// Asynchronously create a new resource by POSTing the given object to the URI template,
/// and returns the response with no entity as <see cref="HttpResponseMessage"/>.
/// </summary>
/// <remarks>
/// <para>
/// URI Template variables are expanded using the given dictionary.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>The HTTP response message with no entity.</returns>
/// <param name="postCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous POST method completes.
/// </param>
void PostForMessageAsync(string url, object request, IDictionary<string, object> uriVariables, Action<MethodCompletedEventArgs<HttpResponseMessage>> postCompleted);
/// <summary>
/// Create a new resource by POSTing the given object to the URI template,
/// Asynchronously create a new resource by POSTing the given object to the URI template,
/// and returns the response with no entity as <see cref="HttpResponseMessage"/>.
/// </summary>
/// <remarks>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <returns>The HTTP response message with no entity.</returns>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="postCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous POST method completes.
/// </param>
void PostForMessageAsync(Uri url, object request, Action<MethodCompletedEventArgs<HttpResponseMessage>> postCompleted);
#endregion
@@ -352,45 +382,51 @@ namespace Spring.Http.Rest
#region PUT
/// <summary>
/// Create or update a resource by PUTting the given object to the URI.
/// Asynchronously create or update a resource by PUTting the given object to the URI.
/// </summary>
/// <remarks>
/// <para>
/// URI Template variables are expanded using the given URI variables, if any.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be PUT, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <param name="putCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous PUT method completes.
/// </param>
void PutAsync(string url, object request, object[] uriVariables, Action<MethodCompletedEventArgs<object>> putCompleted);
/// <summary>
/// Create or update a resource by PUTting the given object to the URI.
/// Asynchronously create or update a resource by PUTting the given object to the URI.
/// </summary>
/// <remarks>
/// <para>
/// URI Template variables are expanded using the given dictionary.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be PUT, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <param name="putCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous PUT method completes.
/// </param>
void PutAsync(string url, object request, IDictionary<string, object> uriVariables, Action<MethodCompletedEventArgs<object>> putCompleted);
/// <summary>
/// Create or update a resource by PUTting the given object to the URI.
/// Asynchronously create or update a resource by PUTting the given object to the URI.
/// </summary>
/// <remarks>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be PUT, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="putCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous PUT method completes.
/// </param>
void PutAsync(Uri url, object request, Action<MethodCompletedEventArgs<object>> putCompleted);
#endregion
@@ -398,29 +434,38 @@ namespace Spring.Http.Rest
#region DELETE
/// <summary>
/// Delete the resources at the specified URI.
/// Asynchronously delete the resources at the specified URI.
/// </summary>
/// <remarks>
/// URI Template variables are expanded using the given URI variables, if any.
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <param name="deleteCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous PUT method completes.
/// </param>
void DeleteAsync(string url, object[] uriVariables, Action<MethodCompletedEventArgs<object>> deleteCompleted);
/// <summary>
/// Delete the resources at the specified URI.
/// Asynchronously delete the resources at the specified URI.
/// </summary>
/// <remarks>
/// URI Template variables are expanded using the given dictionary.
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <param name="deleteCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous PUT method completes.
/// </param>
void DeleteAsync(string url, IDictionary<string, object> uriVariables, Action<MethodCompletedEventArgs<object>> deleteCompleted);
/// <summary>
/// Delete the resources at the specified URI.
/// Asynchronously delete the resources at the specified URI.
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="deleteCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous PUT method completes.
/// </param>
void DeleteAsync(Uri url, Action<MethodCompletedEventArgs<object>> deleteCompleted);
#endregion
@@ -428,32 +473,38 @@ namespace Spring.Http.Rest
#region OPTIONS
/// <summary>
/// Return the value of the Allow header for the given URI.
/// Asynchronously return the value of the Allow header for the given URI.
/// </summary>
/// <remarks>
/// URI Template variables are expanded using the given URI variables, if any.
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>The value of the allow header.</returns>
/// <param name="optionsCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous OPTIONS method completes.
/// </param>
void OptionsForAllowAsync(string url, object[] uriVariables, Action<IList<HttpMethod>> optionsCompleted);
/// <summary>
/// Return the value of the Allow header for the given URI.
/// Asynchronously return the value of the Allow header for the given URI.
/// </summary>
/// <remarks>
/// URI Template variables are expanded using the given dictionary.
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>The value of the allow header.</returns>
/// <param name="optionsCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous OPTIONS method completes.
/// </param>
void OptionsForAllowAsync(string url, IDictionary<string, object> uriVariables, Action<IList<HttpMethod>> optionsCompleted);
/// <summary>
/// Return the value of the Allow header for the given URI.
/// Asynchronously return the value of the Allow header for the given URI.
/// </summary>
/// <param name="url">The URL.</param>
/// <returns>The value of the allow header.</returns>
/// <param name="optionsCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous OPTIONS method completes.
/// </param>
void OptionsForAllowAsync(Uri url, Action<IList<HttpMethod>> optionsCompleted);
#endregion
@@ -462,7 +513,7 @@ namespace Spring.Http.Rest
#region Exchange
/// <summary>
/// Execute the HTTP method to the given URI template, writing the given request message to the request,
/// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request,
/// and returns the response as <see cref="HttpResponseMessage{T}"/>.
/// </summary>
/// <remarks>
@@ -475,11 +526,13 @@ namespace Spring.Http.Rest
/// The HTTP entity (headers and/or body) to write to the request, may be <see langword="null"/>.
/// </param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>The HTTP response message.</returns>
/// <param name="methodCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous method completes.
/// </param>
void ExchangeAsync<T>(string url, HttpMethod method, HttpEntity requestEntity, object[] uriVariables, Action<MethodCompletedEventArgs<HttpResponseMessage<T>>> methodCompleted) where T : class;
/// <summary>
/// Execute the HTTP method to the given URI template, writing the given request message to the request,
/// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request,
/// and returns the response as <see cref="HttpResponseMessage{T}"/>.
/// </summary>
/// <remarks>
@@ -492,11 +545,13 @@ namespace Spring.Http.Rest
/// The HTTP entity (headers and/or body) to write to the request, may be <see langword="null"/>.
/// </param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>The HTTP response message.</returns>
/// <param name="methodCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous method completes.
/// </param>
void ExchangeAsync<T>(string url, HttpMethod method, HttpEntity requestEntity, IDictionary<string, object> uriVariables, Action<MethodCompletedEventArgs<HttpResponseMessage<T>>> methodCompleted) where T : class;
/// <summary>
/// Execute the HTTP method to the given URI template, writing the given request message to the request,
/// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request,
/// and returns the response as <see cref="HttpResponseMessage{T}"/>.
/// </summary>
/// <typeparam name="T">The type of the response value.</typeparam>
@@ -505,11 +560,13 @@ namespace Spring.Http.Rest
/// <param name="requestEntity">
/// The HTTP entity (headers and/or body) to write to the request, may be <see langword="null"/>.
/// </param>
/// <returns>The HTTP response message.</returns>
/// <param name="methodCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous method completes.
/// </param>
void ExchangeAsync<T>(Uri url, HttpMethod method, HttpEntity requestEntity, Action<MethodCompletedEventArgs<HttpResponseMessage<T>>> methodCompleted) where T : class;
/// <summary>
/// Execute the HTTP method to the given URI template, writing the given request message to the request,
/// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request,
/// and returns the response with no entity as <see cref="HttpResponseMessage"/>.
/// </summary>
/// <remarks>
@@ -521,11 +578,13 @@ namespace Spring.Http.Rest
/// The HTTP entity (headers and/or body) to write to the request, may be <see langword="null"/>.
/// </param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>The HTTP response message with no entity.</returns>
/// <param name="methodCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous method completes.
/// </param>
void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, object[] uriVariables, Action<MethodCompletedEventArgs<HttpResponseMessage>> methodCompleted);
/// <summary>
/// Execute the HTTP method to the given URI template, writing the given request message to the request,
/// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request,
/// and returns the response with no entity as <see cref="HttpResponseMessage"/>.
/// </summary>
/// <remarks>
@@ -537,11 +596,13 @@ namespace Spring.Http.Rest
/// The HTTP entity (headers and/or body) to write to the request, may be <see langword="null"/>.
/// </param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>The HTTP response message with no entity.</returns>
/// <param name="methodCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous method completes.
/// </param>
void ExchangeAsync(string url, HttpMethod method, HttpEntity requestEntity, IDictionary<string, object> uriVariables, Action<MethodCompletedEventArgs<HttpResponseMessage>> methodCompleted);
/// <summary>
/// Execute the HTTP method to the given URI template, writing the given request message to the request,
/// Asynchronously execute the HTTP method to the given URI template, writing the given request message to the request,
/// and returns the response with no entity as <see cref="HttpResponseMessage"/>.
/// </summary>
/// <param name="url">The URL.</param>
@@ -549,7 +610,9 @@ namespace Spring.Http.Rest
/// <param name="requestEntity">
/// The HTTP entity (headers and/or body) to write to the request, may be <see langword="null"/>.
/// </param>
/// <returns>The HTTP response message with no entity.</returns>
/// <param name="methodCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous method completes.
/// </param>
void ExchangeAsync(Uri url, HttpMethod method, HttpEntity requestEntity, Action<MethodCompletedEventArgs<HttpResponseMessage>> methodCompleted);
#endregion
@@ -557,7 +620,7 @@ namespace Spring.Http.Rest
#region General execution
/// <summary>
/// Execute the HTTP method to the given URI template, preparing the request with the
/// Asynchronously execute the HTTP method to the given URI template, preparing the request with the
/// <see cref="IRequestCallback"/>, and reading the response with an <see cref="IResponseExtractor{T}"/>.
/// </summary>
/// <remarks>
@@ -569,11 +632,13 @@ namespace Spring.Http.Rest
/// <param name="requestCallback">Object that prepares the request.</param>
/// <param name="responseExtractor">Object that extracts the return value from the response.</param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>An arbitrary object, as returned by the <see cref="IResponseExtractor{T}"/>.</returns>
/// <param name="methodCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous method completes.
/// </param>
void ExecuteAsync<T>(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor<T> responseExtractor, object[] uriVariables, Action<MethodCompletedEventArgs<T>> methodCompleted) where T : class;
/// <summary>
/// Execute the HTTP method to the given URI template, preparing the request with the
/// Asynchronously execute the HTTP method to the given URI template, preparing the request with the
/// <see cref="IRequestCallback"/>, and reading the response with an <see cref="IResponseExtractor{T}"/>.
/// </summary>
/// <remarks>
@@ -585,11 +650,13 @@ namespace Spring.Http.Rest
/// <param name="requestCallback">Object that prepares the request.</param>
/// <param name="responseExtractor">Object that extracts the return value from the response.</param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>An arbitrary object, as returned by the <see cref="IResponseExtractor{T}"/>.</returns>
/// <param name="methodCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous method completes.
/// </param>
void ExecuteAsync<T>(string url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor<T> responseExtractor, IDictionary<string, object> uriVariables, Action<MethodCompletedEventArgs<T>> methodCompleted) where T : class;
/// <summary>
/// Execute the HTTP method to the given URI template, preparing the request with the
/// Asynchronously execute the HTTP method to the given URI template, preparing the request with the
/// <see cref="IRequestCallback"/>, and reading the response with an <see cref="IResponseExtractor{T}"/>.
/// </summary>
/// <typeparam name="T">The type of the response value.</typeparam>
@@ -597,7 +664,9 @@ namespace Spring.Http.Rest
/// <param name="method">The HTTP method (GET, POST, etc.)</param>
/// <param name="requestCallback">Object that prepares the request.</param>
/// <param name="responseExtractor">Object that extracts the return value from the response.</param>
/// <returns>An arbitrary object, as returned by the <see cref="IResponseExtractor{T}"/>.</returns>
/// <param name="methodCompleted">
/// The <code>Action&lt;T&gt;</code> to perform when the asynchronous method completes.
/// </param>
void ExecuteAsync<T>(Uri url, HttpMethod method, IRequestCallback requestCallback, IResponseExtractor<T> responseExtractor, Action<MethodCompletedEventArgs<T>> methodCompleted) where T : class;
#endregion

View File

@@ -38,9 +38,6 @@ namespace Spring.Http.Rest
/// <author>Bruno Baia (.NET)</author>
public interface IRestOperations
{
// TODO : use object[] instead of string[]
// TODO : use IDictionary<string, object> instead of IDictionary<string, string>
#region GET
/// <summary>
@@ -159,12 +156,11 @@ namespace Spring.Http.Rest
/// <para>
/// URI Template variables are expanded using the given URI variables, if any.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>The value for the Location header.</returns>
Uri PostForLocation(string url, object request, params object[] uriVariables);
@@ -178,12 +174,11 @@ namespace Spring.Http.Rest
/// <para>
/// URI Template variables are expanded using the given dictionary.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>The value for the Location header.</returns>
Uri PostForLocation(string url, object request, IDictionary<string, object> uriVariables);
@@ -193,11 +188,10 @@ namespace Spring.Http.Rest
/// and returns the value of the 'Location' header.
/// This header typically indicates where the new resource is stored.
/// </summary>
/// <remarks>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <returns>The value for the Location header.</returns>
Uri PostForLocation(Uri url, object request);
@@ -209,13 +203,12 @@ namespace Spring.Http.Rest
/// <para>
/// URI Template variables are expanded using the given URI variables, if any.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>The converted object.</returns>
T PostForObject<T>(string url, object request, params object[] uriVariables) where T : class;
@@ -228,13 +221,12 @@ namespace Spring.Http.Rest
/// <para>
/// URI Template variables are expanded using the given dictionary.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>The converted object.</returns>
T PostForObject<T>(string url, object request, IDictionary<string, object> uriVariables) where T : class;
@@ -243,12 +235,11 @@ namespace Spring.Http.Rest
/// Create a new resource by POSTing the given object to the URI template,
/// and returns the representation found in the response.
/// </summary>
/// <remarks>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </remarks>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <returns>The converted object.</returns>
T PostForObject<T>(Uri url, object request) where T : class;
@@ -260,13 +251,12 @@ namespace Spring.Http.Rest
/// <para>
/// URI Template variables are expanded using the given URI variables, if any.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>The HTTP response message.</returns>
HttpResponseMessage<T> PostForMessage<T>(string url, object request, params object[] uriVariables) where T : class;
@@ -279,13 +269,12 @@ namespace Spring.Http.Rest
/// <para>
/// URI Template variables are expanded using the given dictionary.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>The HTTP response message.</returns>
HttpResponseMessage<T> PostForMessage<T>(string url, object request, IDictionary<string, object> uriVariables) where T : class;
@@ -294,12 +283,11 @@ namespace Spring.Http.Rest
/// Create a new resource by POSTing the given object to the URI template,
/// and returns the response as <see cref="HttpResponseMessage{T}"/>.
/// </summary>
/// <remarks>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </remarks>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <returns>The HTTP response message.</returns>
HttpResponseMessage<T> PostForMessage<T>(Uri url, object request) where T : class;
@@ -311,12 +299,11 @@ namespace Spring.Http.Rest
/// <para>
/// URI Template variables are expanded using the given URI variables, if any.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The variables to expand the template.</param>
/// <returns>The HTTP response message with no entity.</returns>
HttpResponseMessage PostForMessage(string url, object request, params object[] uriVariables);
@@ -329,12 +316,11 @@ namespace Spring.Http.Rest
/// <para>
/// URI Template variables are expanded using the given dictionary.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
/// <returns>The HTTP response message with no entity.</returns>
HttpResponseMessage PostForMessage(string url, object request, IDictionary<string, object> uriVariables);
@@ -343,11 +329,10 @@ namespace Spring.Http.Rest
/// Create a new resource by POSTing the given object to the URI template,
/// and returns the response with no entity as <see cref="HttpResponseMessage"/>.
/// </summary>
/// <remarks>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be POSTed, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <returns>The HTTP response message with no entity.</returns>
HttpResponseMessage PostForMessage(Uri url, object request);
@@ -362,12 +347,11 @@ namespace Spring.Http.Rest
/// <para>
/// URI Template variables are expanded using the given URI variables, if any.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be PUT, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The variables to expand the template.</param>
void Put(string url, object request, params object[] uriVariables);
@@ -378,23 +362,21 @@ namespace Spring.Http.Rest
/// <para>
/// URI Template variables are expanded using the given dictionary.
/// </para>
/// <para>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </para>
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be PUT, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
/// <param name="uriVariables">The dictionary containing variables for the URI template.</param>
void Put(string url, object request, IDictionary<string, object> uriVariables);
/// <summary>
/// Create or update a resource by PUTting the given object to the URI.
/// </summary>
/// <remarks>
/// The request parameter can be a <see cref="HttpEntity"/> in order to add additional HTTP headers to the request.
/// </remarks>
/// <param name="url">The URL.</param>
/// <param name="request">The Object to be PUT, may be null.</param>
/// <param name="request">
/// The object to be POSTed, may be a <see cref="HttpEntity"/> in order to add additional HTTP headers.
/// </param>
void Put(Uri url, object request);
#endregion

View File

@@ -23,24 +23,42 @@ using System.ComponentModel;
namespace Spring.Http.Rest
{
// TODO: Rename this to RestOperationCompletedEventArgs or RestAsyncCompletedEventArgs ?
/// <summary>
/// Provides data when an asynchronous REST operation completes.
/// </summary>
/// <typeparam name="T">The type of the response value.</typeparam>
/// <see cref="IRestAsyncOperations"/>
/// <see cref="RestTemplate"/>
public class MethodCompletedEventArgs<T> : AsyncCompletedEventArgs where T : class
{
private T response;
/// <summary>
/// Gest the response of the REST operation.
/// </summary>
/// <exception cref="System.InvalidOperationException">If the operation was canceled.</exception>
/// <exception cref="System.Reflection.TargetInvocationException">If the operation failed.</exception>
public T Response
{
get
{
// Raise an exception if the operation failed or
// was canceled.
// Raise an exception if the operation failed or was canceled.
base.RaiseExceptionIfNecessary();
// If the operation was successful, return the
// property value.
// If the operation was successful, return the value.
return response;
}
}
/// <summary>
/// Creates a new instance of <see cref="MethodCompletedEventArgs{T}"/>.
/// </summary>
/// <param name="response">The response of the REST operation.</param>
/// <param name="exception">Any error that occurred during the asynchronous operation.</param>
/// <param name="cancelled">A value indicating whether the asynchronous operation was canceled.</param>
/// <param name="userState">The optional user-supplied state object.</param>
public MethodCompletedEventArgs(T response, Exception exception, bool cancelled, object userState)
: base(exception, cancelled, userState)
{

File diff suppressed because it is too large Load Diff

View File

@@ -23,6 +23,8 @@ using System.Globalization;
namespace Spring.Util
{
// From Spring.Core
/// <summary>
/// Assertion utility methods that simplify things such as argument checks.
/// </summary>

View File

@@ -22,6 +22,8 @@ using System;
namespace Spring.Util
{
// From Spring.Core
/// <summary>
/// Miscellaneous <see cref="System.String"/> utility methods.
/// </summary>

View File

@@ -129,7 +129,7 @@ namespace Spring.Http.Converters
}
[Test]
[Ignore] //TODO: relative path
[Ignore] //TODO: relative path (needs IResource ?)
public void WriteMultipart()
{
MemoryStream requestStream = new MemoryStream();