Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions RestSharp.MonoDroid/Extensions/ResponseStatusExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Net;

namespace RestSharp.Extensions
{
public static class ResponseStatusExtensions
{
/// <summary>
/// Convert a <see cref="ResponseStatus"/> to a <see cref="WebException"/> instance.
/// </summary>
/// <param name="responseStatus">The response status.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentOutOfRangeException">responseStatus</exception>
public static WebException ToWebException(this ResponseStatus responseStatus)
{
switch (responseStatus)
{
case ResponseStatus.None:
return new WebException("The request could not be processed.", WebExceptionStatus.ServerProtocolViolation);
case ResponseStatus.Error:
return new WebException("An error occured while processing the request.", WebExceptionStatus.ServerProtocolViolation);
case ResponseStatus.TimedOut:
return new WebException("The request timed-out.", WebExceptionStatus.Timeout);
case ResponseStatus.Aborted:
return new WebException("The request was aborted.", WebExceptionStatus.Timeout);
default:
throw new ArgumentOutOfRangeException("responseStatus");
}
}
}
}
1 change: 1 addition & 0 deletions RestSharp.MonoDroid/RestSharp.MonoDroid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@
<Compile Include="..\RestSharp\SharedAssemblyInfo.cs">
<Link>SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Extensions\ResponseStatusExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Novell\Novell.MonoDroid.CSharp.targets" />
Expand Down
31 changes: 31 additions & 0 deletions RestSharp.MonoTouch/Extensions/ResponseStatusExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Net;

namespace RestSharp.Extensions
{
public static class ResponseStatusExtensions
{
/// <summary>
/// Convert a <see cref="ResponseStatus"/> to a <see cref="WebException"/> instance.
/// </summary>
/// <param name="responseStatus">The response status.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentOutOfRangeException">responseStatus</exception>
public static WebException ToWebException(this ResponseStatus responseStatus)
{
switch (responseStatus)
{
case ResponseStatus.None:
return new WebException("The request could not be processed.", WebExceptionStatus.ServerProtocolViolation);
case ResponseStatus.Error:
return new WebException("An error occured while processing the request.", WebExceptionStatus.ServerProtocolViolation);
case ResponseStatus.TimedOut:
return new WebException("The request timed-out.", WebExceptionStatus.Timeout);
case ResponseStatus.Aborted:
return new WebException("The request was aborted.", WebExceptionStatus.Timeout);
default:
throw new ArgumentOutOfRangeException("responseStatus");
}
}
}
}
1 change: 1 addition & 0 deletions RestSharp.MonoTouch/RestSharp.MonoTouch.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@
<Compile Include="..\RestSharp\SharedAssemblyInfo.cs">
<Link>SharedAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Extensions\ResponseStatusExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions RestSharp/IRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using System.Net;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
#if NET4
#if NET4 || MONODROID || MONOTOUCH
using System.Threading;
using System.Threading.Tasks;
#endif
Expand Down Expand Up @@ -123,7 +123,7 @@ public interface IRestClient
IRestResponse<T> ExecuteAsPost<T>(IRestRequest request, string httpMethod) where T : new();
#endif

#if NET4
#if NET4 || MONODROID || MONOTOUCH
/// <summary>
/// Executes the request and callback asynchronously, authenticating if needed
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions RestSharp/RestClient.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
#if NET4
#if NET4 || MONODROID || MONOTOUCH
using System.Threading.Tasks;
#endif
using System.Text;
Expand Down Expand Up @@ -158,7 +158,7 @@ private void DeserializeResponse<T>(IRestRequest request, Action<IRestResponse<T
callback(restResponse, asyncHandle);
}

#if NET4
#if NET4 || MONODROID || MONOTOUCH
/// <summary>
/// Executes a GET-style request asynchronously, authenticating if needed
/// </summary>
Expand Down