diff --git a/src/Documentation/Documentation.Portable.shfbproj b/src/Documentation/Documentation.Portable.shfbproj new file mode 100644 index 0000000..f9df3a2 --- /dev/null +++ b/src/Documentation/Documentation.Portable.shfbproj @@ -0,0 +1,108 @@ + + + + + Debug + AnyCPU + 2.0 + {89f7811c-b169-430a-87fd-895865c3fbdc} + 1.9.9.0 + + Documentation + Documentation + Documentation + + .NET Portable Library 4.0 %28Legacy%29 + .\Help\portable-net40\ + SimpleRESTServices + en-US + + + + OnlyWarningsAndErrors + HtmlHelp1, Website + False + True + False + False + True + Standard + Blank + API Reference + True + VS2013 + True + MemberName + SimpleRESTServices API Reference Documentation + openstack.net%40lists.rackspace.com + AboveNamespaces + Msdn + Msdn + True + True + Attributes, ExplicitInterfaceImplementations, InheritedMembers, InheritedFrameworkMembers, Protected, ProtectedInternalAsProtected, SealedProtected + + + + + + + + + + + + + + + + + + + + + 2 + False + + + + + + + + + + + + + + + + + + + + + SimpleRestServices.Portable + {1960d862-8ad9-48be-9290-b7e23ea03d5c} + True + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/SimpleRestServices.sln b/src/SimpleRestServices.sln index 6f7aa61..63cc096 100644 --- a/src/SimpleRestServices.sln +++ b/src/SimpleRestServices.sln @@ -20,6 +20,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleRestServices.v3.5", " EndProject Project("{7CF6DF6D-3B04-46F8-A40B-537D21BCA0B4}") = "Documentation.v3.5", "Documentation\Documentation.v3.5.shfbproj", "{93356B99-D84C-4291-B739-EF8EC6A9B382}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleRestServices.Portable", "SimpleRestServices\SimpleRestServices.Portable.csproj", "{FC3F3205-19B5-4CE0-BB04-2502C99A4B24}" +EndProject +Project("{7CF6DF6D-3B04-46F8-A40B-537D21BCA0B4}") = "Documentation.Portable", "Documentation\Documentation.Portable.shfbproj", "{89F7811C-B169-430A-87FD-895865C3FBDC}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{A57581E8-CE20-4E4A-81AA-B6BB5611D10F}" ProjectSection(SolutionItems) = preProject .nuget\NuGet.Config = .nuget\NuGet.Config @@ -54,6 +58,13 @@ Global {93356B99-D84C-4291-B739-EF8EC6A9B382}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {93356B99-D84C-4291-B739-EF8EC6A9B382}.Release|Any CPU.ActiveCfg = Release|Any CPU {93356B99-D84C-4291-B739-EF8EC6A9B382}.Release|Any CPU.Build.0 = Release|Any CPU + {FC3F3205-19B5-4CE0-BB04-2502C99A4B24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FC3F3205-19B5-4CE0-BB04-2502C99A4B24}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FC3F3205-19B5-4CE0-BB04-2502C99A4B24}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FC3F3205-19B5-4CE0-BB04-2502C99A4B24}.Release|Any CPU.Build.0 = Release|Any CPU + {89F7811C-B169-430A-87FD-895865C3FBDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {89F7811C-B169-430A-87FD-895865C3FBDC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {89F7811C-B169-430A-87FD-895865C3FBDC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/SimpleRestServices/Client/HttpHeader.cs b/src/SimpleRestServices/Client/HttpHeader.cs index 9a65a8c..1994bad 100644 --- a/src/SimpleRestServices/Client/HttpHeader.cs +++ b/src/SimpleRestServices/Client/HttpHeader.cs @@ -6,7 +6,9 @@ namespace JSIStudios.SimpleRESTServices.Client /// /// Represents a single header included with an HTTP response. /// +#if !PORTABLE [Serializable] +#endif [DebuggerDisplay("{Key,nq} = {Value,nq}")] public class HttpHeader { diff --git a/src/SimpleRestServices/Client/Response.cs b/src/SimpleRestServices/Client/Response.cs index 2dea80f..2f8ab4f 100644 --- a/src/SimpleRestServices/Client/Response.cs +++ b/src/SimpleRestServices/Client/Response.cs @@ -8,7 +8,9 @@ namespace JSIStudios.SimpleRESTServices.Client /// Represents the basic response of an HTTP REST request, where the body of the response /// is stored as a text string. /// +#if !PORTABLE [Serializable] +#endif public class Response { /// diff --git a/src/SimpleRestServices/Client/ResponseOfT.cs b/src/SimpleRestServices/Client/ResponseOfT.cs index 4ce9611..3a97ba3 100644 --- a/src/SimpleRestServices/Client/ResponseOfT.cs +++ b/src/SimpleRestServices/Client/ResponseOfT.cs @@ -9,7 +9,9 @@ namespace JSIStudios.SimpleRESTServices.Client /// from the response. /// /// The type of the data included with the response. +#if !PORTABLE [Serializable] +#endif public class Response : Response { /// diff --git a/src/SimpleRestServices/Client/RestServiceBase.cs b/src/SimpleRestServices/Client/RestServiceBase.cs index 26e634a..db80728 100644 --- a/src/SimpleRestServices/Client/RestServiceBase.cs +++ b/src/SimpleRestServices/Client/RestServiceBase.cs @@ -9,6 +9,9 @@ #if !NET35 using System.Diagnostics.Contracts; #endif +#if PORTABLE +using System.Threading.Tasks; +#endif namespace JSIStudios.SimpleRESTServices.Client { @@ -176,6 +179,7 @@ public virtual Response Execute(Uri url, HttpMethod method, Func(req.BeginGetRequestStream(null, null), req.EndGetRequestStream).Result) + { + post.Write(formData, 0, formData.Length); + } +#endif } return body; @@ -321,13 +331,21 @@ public virtual Response Stream(Uri url, HttpMethod method, Func 0 ) { +#if !PORTABLE req.SendChunked = settings.ChunkRequest; req.AllowWriteStreamBuffering = false; req.ContentLength = content.Length > maxReadLength ? maxReadLength : content.Length; +#else + throw new NotSupportedException("This platform does not support chunked HTTP requests."); +#endif } +#if !PORTABLE using (Stream stream = req.GetRequestStream()) +#else + using (Stream stream = Task.Factory.FromAsync(req.BeginGetRequestStream(null, null), req.EndGetRequestStream).Result) +#endif { var buffer = new byte[bufferSize]; int count; @@ -416,16 +434,24 @@ public virtual Response ExecuteRequest(Uri url, HttpMethod method, Func 0 || settings.AllowZeroContentLength) req.ContentLength = settings.ContentLength; +#endif +#if !PORTABLE if (settings.ConnectionLimit != null) req.ServicePoint.ConnectionLimit = settings.ConnectionLimit.Value; +#endif +#if !PORTABLE req.Timeout = (int)settings.Timeout.TotalMilliseconds; +#endif +#if !PORTABLE if (!string.IsNullOrEmpty(settings.UserAgent)) req.UserAgent = settings.UserAgent; +#endif if (settings.Credentials != null) req.Credentials = settings.Credentials; @@ -434,13 +460,21 @@ public virtual Response ExecuteRequest(Uri url, HttpMethod method, Func(req.BeginGetResponse(null, null), req.EndGetResponse).Result as HttpWebResponse) +#endif { if (responseBuilderCallback != null) response = responseBuilderCallback(resp, false); @@ -495,9 +529,15 @@ private Response BuildWebResponse(HttpWebResponse resp) respBody = reader.ReadToEnd(); } +#if !PORTABLE var respHeaders = resp.Headers.AllKeys.Select(key => new HttpHeader(key, resp.GetResponseHeader(key))) .ToList(); +#else + var respHeaders = + resp.Headers.AllKeys.Select(key => new HttpHeader(key, resp.Headers[key])) + .ToList(); +#endif return new Response(resp.StatusCode, respHeaders, respBody); } @@ -524,6 +564,7 @@ private Encoding GetEncoding(HttpWebResponse response) Contract.EndContractBlock(); #endif +#if !PORTABLE string contentEncoding = response.ContentEncoding; if (!string.IsNullOrEmpty(contentEncoding)) { @@ -536,7 +577,9 @@ private Encoding GetEncoding(HttpWebResponse response) // continue below } } +#endif +#if !PORTABLE string characterSet = response.CharacterSet; if (string.IsNullOrEmpty(characterSet)) return Encoding.Default; @@ -547,8 +590,15 @@ private Encoding GetEncoding(HttpWebResponse response) } catch (ArgumentException) { - return Encoding.Default; + // continue below } +#endif + +#if !PORTABLE + return Encoding.Default; +#else + return Encoding.UTF8; +#endif } /// diff --git a/src/SimpleRestServices/Client/UrlBuilder.cs b/src/SimpleRestServices/Client/UrlBuilder.cs index cb8345c..f1b107b 100644 --- a/src/SimpleRestServices/Client/UrlBuilder.cs +++ b/src/SimpleRestServices/Client/UrlBuilder.cs @@ -43,11 +43,19 @@ public string Build(string baseAbsoluteUrl, Dictionary queryStri if (queryStringParameters != null && queryStringParameters.Count > 0) { +#if !PORTABLE var paramsCombinedList = queryStringParameters.Select( param => string.Format("{0}={1}", System.Web.HttpUtility.UrlEncode(param.Key), System.Web.HttpUtility.UrlEncode(param.Value))); +#else + var paramsCombinedList = + queryStringParameters.Select( + param => + string.Format("{0}={1}", Uri.EscapeUriString(param.Key), + Uri.EscapeUriString(param.Value))); +#endif var paramsCombined = string.Join("&", paramsCombinedList.ToArray()); var separator = baseAbsoluteUrl.Contains("?") ? "&" : "?"; diff --git a/src/SimpleRestServices/Client/WebResponseRetryLogic.cs b/src/SimpleRestServices/Client/WebResponseRetryLogic.cs index f74f3e9..40688c3 100644 --- a/src/SimpleRestServices/Client/WebResponseRetryLogic.cs +++ b/src/SimpleRestServices/Client/WebResponseRetryLogic.cs @@ -59,7 +59,16 @@ public Response Execute(Func callback, IEnumerable non retryCount--; if (retryCount >= 0) + { +#if !PORTABLE Thread.Sleep(retryDelay ?? TimeSpan.Zero); +#else + using (ManualResetEvent ev = new ManualResetEvent(false)) + { + ev.WaitOne(retryDelay ?? TimeSpan.Zero); + } +#endif + } } while (retryCount > 0); diff --git a/src/SimpleRestServices/Properties/AssemblyInfo.cs b/src/SimpleRestServices/Properties/AssemblyInfo.cs index 188da4c..2eccd7c 100644 --- a/src/SimpleRestServices/Properties/AssemblyInfo.cs +++ b/src/SimpleRestServices/Properties/AssemblyInfo.cs @@ -15,6 +15,7 @@ [assembly: AssemblyCulture("")] [assembly: CLSCompliant(true)] +#if !PORTABLE // 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. @@ -22,6 +23,7 @@ // The following GUID is for the ID of the typelib if this project is exposed to COM [assembly: Guid("5a741815-e26d-4cb0-a42b-78f7c1611190")] +#endif // Refer to the following issue before changing these version numbers: // https://github.com/JSIStudios/SimpleRestServices/issues/53 diff --git a/src/SimpleRestServices/SimpleRestServices.Portable.csproj b/src/SimpleRestServices/SimpleRestServices.Portable.csproj new file mode 100644 index 0000000..004e4a1 --- /dev/null +++ b/src/SimpleRestServices/SimpleRestServices.Portable.csproj @@ -0,0 +1,95 @@ + + + + + Debug + AnyCPU + {FC3F3205-19B5-4CE0-BB04-2502C99A4B24} + Library + Properties + JSIStudios.SimpleRESTServices + SimpleRESTServices + v4.0 + Profile136 + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + obj\portable-net40\ + ..\ + true + + + true + full + false + bin\portable-net40\Debug\ + DEBUG;TRACE;PORTABLE + prompt + 4 + bin\portable-net40\Debug\SimpleRESTServices.xml + + + pdbonly + true + bin\portable-net40\Release\ + TRACE;PORTABLE + prompt + 4 + bin\portable-net40\Release\SimpleRESTServices.xml + + + ..\..\..\keys\simplerestservices.snk + true + + + + False + ..\packages\Newtonsoft.Json.5.0.6\lib\portable-net40+sl4+wp7+win8\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + + simplerestservices.snk + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/src/SimpleRestServices/SimpleRestServices.nuspec b/src/SimpleRestServices/SimpleRestServices.nuspec index a7bb817..0eac718 100644 --- a/src/SimpleRestServices/SimpleRestServices.nuspec +++ b/src/SimpleRestServices/SimpleRestServices.nuspec @@ -28,6 +28,10 @@ + + + + diff --git a/src/SimpleRestServices/packages.SimpleRestServices.Portable.config b/src/SimpleRestServices/packages.SimpleRestServices.Portable.config new file mode 100644 index 0000000..f40aedd --- /dev/null +++ b/src/SimpleRestServices/packages.SimpleRestServices.Portable.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file