Permalink
Browse files

103.1 changes (.net 4 dynamic and fixed invalidcastexception

  • Loading branch information...
1 parent 8d210ec commit 671d80863cb805f637d2051c1ae4ec9879a1a4e5 @johnsheehan johnsheehan committed May 3, 2012
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace RestSharp
+{
+ public static partial class RestClientExtensions
+ {
+ public static RestResponse<dynamic> ExecuteDynamic(this IRestClient client, IRestRequest request)
+ {
+ var response = client.Execute(request);
+
+ var generic = (RestResponse<dynamic>)response;
+ dynamic content = SimpleJson.DeserializeObject(response.Content);
+ generic.Data = content;
+
+ return generic;
+ }
+ }
+}
@@ -0,0 +1,18 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("RestSharp")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("97044cbf-6c9d-4b08-87e3-bf30fbde1933")]
+
+[assembly: InternalsVisibleTo("RestSharp.IntegrationTests")]
@@ -0,0 +1,266 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{5FF943A5-260F-4042-B4CE-C4977BAD4EBB}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>RestSharp</RootNamespace>
+ <AssemblyName>RestSharp</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>TRACE;DEBUG;FRAMEWORK, NET4</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <DocumentationFile>bin\Debug\RestSharp.xml</DocumentationFile>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE;FRAMEWORK, NET4</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ <DocumentationFile>bin\Release\RestSharp.xml</DocumentationFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="..\restsharp\authenticators\HttpBasicAuthenticator.cs">
+ <Link>Authenticators\HttpBasicAuthenticator.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\IAuthenticator.cs">
+ <Link>Authenticators\IAuthenticator.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\NtlmAuthenticator.cs">
+ <Link>Authenticators\NtlmAuthenticator.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\OAuth2Authenticator.cs">
+ <Link>Authenticators\OAuth2Authenticator.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\extensions\CollectionExtensions.cs">
+ <Link>Authenticators\OAuth\Extensions\CollectionExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\extensions\OAuthExtensions.cs">
+ <Link>Authenticators\OAuth\Extensions\OAuthExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\extensions\StringExtensions.cs">
+ <Link>Authenticators\OAuth\Extensions\StringExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\extensions\TimeExtensions.cs">
+ <Link>Authenticators\OAuth\Extensions\TimeExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\HttpPostParameter.cs">
+ <Link>Authenticators\OAuth\HttpPostParameter.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\HttpPostParameterType.cs">
+ <Link>Authenticators\OAuth\HttpPostParameterType.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\OAuthParameterHandling.cs">
+ <Link>Authenticators\OAuth\OAuthParameterHandling.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\OAuthSignatureMethod.cs">
+ <Link>Authenticators\OAuth\OAuthSignatureMethod.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\OAuthSignatureTreatment.cs">
+ <Link>Authenticators\OAuth\OAuthSignatureTreatment.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\OAuthTools.cs">
+ <Link>Authenticators\OAuth\OAuthTools.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\OAuthType.cs">
+ <Link>Authenticators\OAuth\OAuthType.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\OAuthWebQueryInfo.cs">
+ <Link>Authenticators\OAuth\OAuthWebQueryInfo.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\OAuthWorkflow.cs">
+ <Link>Authenticators\OAuth\OAuthWorkflow.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\WebPair.cs">
+ <Link>Authenticators\OAuth\WebPair.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\WebPairCollection.cs">
+ <Link>Authenticators\OAuth\WebPairCollection.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\WebParameter.cs">
+ <Link>Authenticators\OAuth\WebParameter.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\oauth\WebParameterCollection.cs">
+ <Link>Authenticators\OAuth\WebParameterCollection.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\authenticators\SimpleAuthenticator.cs">
+ <Link>Authenticators\SimpleAuthenticator.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\deserializers\DeserializeAsAttribute.cs">
+ <Link>Deserializers\DeserializeAsAttribute.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\deserializers\DotNetXmlDeserializer.cs">
+ <Link>Deserializers\DotNetXmlDeserializer.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\deserializers\IDeserializer.cs">
+ <Link>Deserializers\IDeserializer.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\deserializers\JsonDeserializer.cs">
+ <Link>Deserializers\JsonDeserializer.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\deserializers\XmlAttributeDeserializer.cs">
+ <Link>Deserializers\XmlAttributeDeserializer.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\deserializers\XmlDeserializer.cs">
+ <Link>Deserializers\XmlDeserializer.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\Enum.cs">
+ <Link>Enum.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\extensions\MiscExtensions.cs">
+ <Link>Extensions\MiscExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\Extensions\MonoHttp\Helpers.cs">
+ <Link>Extensions\MonoHttp\Helpers.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\Extensions\MonoHttp\HtmlEncoder.cs">
+ <Link>Extensions\MonoHttp\HtmlEncoder.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\Extensions\MonoHttp\HttpUtility.cs">
+ <Link>Extensions\MonoHttp\HttpUtility.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\extensions\ReflectionExtensions.cs">
+ <Link>Extensions\ReflectionExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\extensions\ResponseExtensions.cs">
+ <Link>Extensions\ResponseExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\extensions\StringExtensions.cs">
+ <Link>Extensions\StringExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\extensions\XmlExtensions.cs">
+ <Link>Extensions\XmlExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\FileParameter.cs">
+ <Link>FileParameter.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\Http.Async.cs">
+ <Link>Http.Async.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\Http.cs">
+ <Link>Http.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\Http.Sync.cs">
+ <Link>Http.Sync.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\HttpCookie.cs">
+ <Link>HttpCookie.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\HttpFile.cs">
+ <Link>HttpFile.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\HttpHeader.cs">
+ <Link>HttpHeader.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\HttpParameter.cs">
+ <Link>HttpParameter.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\HttpResponse.cs">
+ <Link>HttpResponse.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\IHttp.cs">
+ <Link>IHttp.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\IHttpFactory.cs">
+ <Link>IHttpFactory.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\IHttpResponse.cs">
+ <Link>IHttpResponse.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\IRestClient.cs">
+ <Link>IRestClient.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\IRestRequest.cs">
+ <Link>IRestRequest.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\IRestResponse.cs">
+ <Link>IRestResponse.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\Parameter.cs">
+ <Link>Parameter.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\RestClient.Async.cs">
+ <Link>RestClient.Async.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\RestClient.cs">
+ <Link>RestClient.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\RestClient.Sync.cs">
+ <Link>RestClient.Sync.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\RestClientExtensions.cs">
+ <Link>RestClientExtensions.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\RestRequest.cs">
+ <Link>RestRequest.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\RestRequestAsyncHandle.cs">
+ <Link>RestRequestAsyncHandle.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\RestResponse.cs">
+ <Link>RestResponse.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\RestResponseCookie.cs">
+ <Link>RestResponseCookie.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\serializers\DotNetXmlSerializer.cs">
+ <Link>Serializers\DotNetXmlSerializer.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\serializers\ISerializer.cs">
+ <Link>Serializers\ISerializer.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\serializers\JsonSerializer.cs">
+ <Link>Serializers\JsonSerializer.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\serializers\SerializeAsAttribute.cs">
+ <Link>Serializers\SerializeAsAttribute.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\serializers\XmlSerializer.cs">
+ <Link>Serializers\XmlSerializer.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\SharedAssemblyInfo.cs">
+ <Link>SharedAssemblyInfo.cs</Link>
+ </Compile>
+ <Compile Include="..\RestSharp\SimpleJson.cs">
+ <Link>SimpleJson.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\validation\Require.cs">
+ <Link>Validation\Require.cs</Link>
+ </Compile>
+ <Compile Include="..\restsharp\validation\Validate.cs">
+ <Link>Validation\Validate.cs</Link>
+ </Compile>
+ <Compile Include="Extensions\RestClientExtensions.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
View
@@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{E709A928
restsharp.nuspec = restsharp.nuspec
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RestSharp.Net4", "RestSharp.Net4\RestSharp.Net4.csproj", "{5FF943A5-260F-4042-B4CE-C4977BAD4EBB}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -79,6 +81,16 @@ Global
{F4D48DF6-316E-4963-B5C1-59CA39B431B7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{F4D48DF6-316E-4963-B5C1-59CA39B431B7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{F4D48DF6-316E-4963-B5C1-59CA39B431B7}.Release|x86.ActiveCfg = Release|Any CPU
+ {5FF943A5-260F-4042-B4CE-C4977BAD4EBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5FF943A5-260F-4042-B4CE-C4977BAD4EBB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5FF943A5-260F-4042-B4CE-C4977BAD4EBB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {5FF943A5-260F-4042-B4CE-C4977BAD4EBB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {5FF943A5-260F-4042-B4CE-C4977BAD4EBB}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {5FF943A5-260F-4042-B4CE-C4977BAD4EBB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5FF943A5-260F-4042-B4CE-C4977BAD4EBB}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5FF943A5-260F-4042-B4CE-C4977BAD4EBB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {5FF943A5-260F-4042-B4CE-C4977BAD4EBB}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {5FF943A5-260F-4042-B4CE-C4977BAD4EBB}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -7,7 +7,7 @@ namespace RestSharp.Extensions
{
public static class ResponseExtensions
{
- public static IRestResponse<T> toAsyncResponse<T>(this IRestResponse response) where T : new()
+ public static IRestResponse<T> toAsyncResponse<T>(this IRestResponse response)
{
return new RestResponse<T>
{
@@ -63,7 +63,7 @@ public interface IRestClient
///
/// </summary>
/// <param name="request"></param>
- RestRequestAsyncHandle ExecuteAsync<T>(IRestRequest request, Action<IRestResponse<T>, RestRequestAsyncHandle> callback) where T : new();
+ RestRequestAsyncHandle ExecuteAsync<T>(IRestRequest request, Action<IRestResponse<T>, RestRequestAsyncHandle> callback);
#if FRAMEWORK
/// <summary>
@@ -94,11 +94,11 @@ private void ProcessResponse(HttpResponse httpResponse, RestRequestAsyncHandle a
/// <typeparam name="T">Target deserialization type</typeparam>
/// <param name="request">Request to be executed</param>
/// <param name="callback">Callback function to be executed upon completion</param>
- public virtual RestRequestAsyncHandle ExecuteAsync<T>(IRestRequest request, Action<IRestResponse<T>, RestRequestAsyncHandle> callback) where T : new()
+ public virtual RestRequestAsyncHandle ExecuteAsync<T>(IRestRequest request, Action<IRestResponse<T>, RestRequestAsyncHandle> callback)
{
return ExecuteAsync(request, (response, asyncHandle) =>
{
- var restResponse = (IRestResponse<T>)response;
+ IRestResponse<T> restResponse = response as RestResponse<T>;
if (response.ResponseStatus != ResponseStatus.Aborted)
{
restResponse = Deserialize<T>(request, response);
@@ -488,7 +488,7 @@ private RestResponse ConvertToRestResponse(HttpResponse httpResponse)
return restResponse;
}
- private IRestResponse<T> Deserialize<T>(IRestRequest request, IRestResponse raw) where T : new()
+ private IRestResponse<T> Deserialize<T>(IRestRequest request, IRestResponse raw)
{
request.OnBeforeDeserialization(raw);
@@ -2,7 +2,7 @@
namespace RestSharp
{
- public static class RestClientExtensions
+ public static partial class RestClientExtensions
{
/// <summary>
/// Executes the request and callback asynchronously, authenticating if needed
Oops, something went wrong.

0 comments on commit 671d808

Please sign in to comment.