diff --git a/Samples/SampleWdpClient.UniversalWindows/Settings.StyleCop b/Samples/SampleWdpClient.UniversalWindows/Settings.StyleCop
new file mode 100644
index 0000000..6d356bc
--- /dev/null
+++ b/Samples/SampleWdpClient.UniversalWindows/Settings.StyleCop
@@ -0,0 +1,824 @@
+
+
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Samples/SampleWdpClient/Settings.StyleCop b/Samples/SampleWdpClient/Settings.StyleCop
new file mode 100644
index 0000000..6d356bc
--- /dev/null
+++ b/Samples/SampleWdpClient/Settings.StyleCop
@@ -0,0 +1,824 @@
+
+
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+ False
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Samples/XboxWdpDriver/XboxWdpDriver.csproj b/Samples/XboxWdpDriver/XboxWdpDriver.csproj
index f1cddab..f4b9e95 100644
--- a/Samples/XboxWdpDriver/XboxWdpDriver.csproj
+++ b/Samples/XboxWdpDriver/XboxWdpDriver.csproj
@@ -78,7 +78,6 @@
-
-
+
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/HttpMultipartFileContent.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/HttpMultipartFileContent.cs
new file mode 100644
index 0000000..f036ca1
--- /dev/null
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/HttpMultipartFileContent.cs
@@ -0,0 +1,141 @@
+//----------------------------------------------------------------------------------------------
+//
+// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
+//
+//----------------------------------------------------------------------------------------------
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Microsoft.Tools.WindowsDevicePortal
+{
+ ///
+ /// This class mimicks , with two main differences
+ /// 1. Simplifies posting files by taking file names instead of managing streams.
+ /// 2. Does not quote the boundaries, due to a bug in the device portal
+ ///
+ internal sealed class HttpMultipartFileContent : HttpContent
+ {
+ ///
+ /// List of items to transfer
+ ///
+ private List items = new List();
+
+ ///
+ /// Boundary string
+ ///
+ private string boundaryString;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public HttpMultipartFileContent() : this(Guid.NewGuid().ToString())
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The boundary string for file content.
+ public HttpMultipartFileContent(string boundary)
+ {
+ this.boundaryString = boundary;
+ Headers.TryAddWithoutValidation("Content-Type", string.Format("multipart/form-data; boundary={0}", this.boundaryString));
+ }
+
+ ///
+ /// Adds a file to the list of items to transfer
+ ///
+ /// The name of the file to add
+ public void Add(string filename)
+ {
+ if (filename != null)
+ {
+ this.items.Add(filename);
+ }
+ }
+
+ ///
+ /// Adds a range of files to the list of items to transfer
+ ///
+ /// List of files to add
+ public void AddRange(IEnumerable filenames)
+ {
+ if (filenames != null)
+ {
+ this.items.AddRange(filenames);
+ }
+ }
+
+ ///
+ /// Serializes the stream.
+ ///
+ /// Serialized Stream
+ /// The Transport Context
+ /// Task tracking progress
+ protected override async Task SerializeToStreamAsync(Stream outStream, TransportContext context)
+ {
+ var boundary = Encoding.ASCII.GetBytes($"--{boundaryString}\r\n");
+ var newline = Encoding.ASCII.GetBytes("\r\n");
+ foreach (var item in this.items)
+ {
+ outStream.Write(boundary, 0, boundary.Length);
+ var headerdata = GetFileHeader(new FileInfo(item));
+ outStream.Write(headerdata, 0, headerdata.Length);
+
+ using (var file = File.OpenRead(item))
+ {
+ await file.CopyToAsync(outStream);
+ }
+
+ outStream.Write(newline, 0, newline.Length);
+ await outStream.FlushAsync();
+ }
+
+ // Close the installation request data.
+ boundary = Encoding.ASCII.GetBytes($"--{boundaryString}--\r\n");
+ outStream.Write(boundary, 0, boundary.Length);
+ await outStream.FlushAsync();
+ }
+
+ ///
+ /// Computes required length for the transfer.
+ ///
+ /// The computed length value
+ /// Whether or not the length was successfully computed
+ protected override bool TryComputeLength(out long length)
+ {
+ length = 0;
+ var boundaryLength = Encoding.ASCII.GetBytes(string.Format("--{0}\r\n", this.boundaryString)).Length;
+ foreach (var item in this.items)
+ {
+ var headerdata = GetFileHeader(new FileInfo(item));
+ length += boundaryLength + headerdata.Length + new FileInfo(item).Length + 2;
+ }
+
+ length += boundaryLength + 2;
+ return true;
+ }
+
+ ///
+ /// Gets the file header for the transfer
+ ///
+ /// Information about the file
+ /// A byte array with the file header information
+ private static byte[] GetFileHeader(FileInfo info)
+ {
+ string contentType = "application/octet-stream";
+ if (info.Extension.ToLower() == ".cer")
+ {
+ contentType = "application/x-x509-ca-cert";
+ }
+
+ return Encoding.ASCII.GetBytes(string.Format("Content-Disposition: form-data; name=\"{0}\"; filename=\"{0}\"\r\nContent-Type: {1}\r\n\r\n", info.Name, contentType));
+ }
+ }
+}
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestPost.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestPost.cs
index 069c77f..e2ad141 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestPost.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestPost.cs
@@ -30,8 +30,7 @@ namespace Microsoft.Tools.WindowsDevicePortal
string requestStreamContentType = null)
{
StreamContent requestContent = null;
- MemoryStream responseDataStream = null;
-
+
if (requestStream != null)
{
requestContent = new StreamContent(requestStream);
@@ -39,6 +38,21 @@ namespace Microsoft.Tools.WindowsDevicePortal
requestContent.Headers.TryAddWithoutValidation(ContentTypeHeaderName, requestStreamContentType);
}
+ return await this.PostAsync(uri, requestContent);
+ }
+
+ ///
+ /// Submits the http post request to the specified uri.
+ ///
+ /// The uri to which the post request will be issued.
+ /// Optional content containing data for the request body.
+ /// Task tracking the completion of the POST request
+ public async Task PostAsync(
+ Uri uri,
+ HttpContent requestContent)
+ {
+ MemoryStream responseDataStream = null;
+
WebRequestHandler requestSettings = new WebRequestHandler();
requestSettings.UseDefaultCredentials = false;
requestSettings.Credentials = this.deviceConnection.Credentials;
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.csproj b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.csproj
index 8b61481..c64db6b 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.csproj
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.csproj
@@ -57,6 +57,7 @@
+
@@ -69,7 +70,6 @@
-
-
+
\ No newline at end of file