diff --git a/Samples/SampleWdpClient.UniversalWindows/App.xaml b/Samples/SampleWdpClient.UniversalWindows/App.xaml
deleted file mode 100644
index b8359102..00000000
--- a/Samples/SampleWdpClient.UniversalWindows/App.xaml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
diff --git a/Samples/SampleWdpClient.UniversalWindows/App.xaml.cs b/Samples/SampleWdpClient.UniversalWindows/App.xaml.cs
deleted file mode 100644
index 7d9d72b7..00000000
--- a/Samples/SampleWdpClient.UniversalWindows/App.xaml.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Runtime.InteropServices.WindowsRuntime;
-using Windows.ApplicationModel;
-using Windows.ApplicationModel.Activation;
-using Windows.Foundation;
-using Windows.Foundation.Collections;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Controls.Primitives;
-using Windows.UI.Xaml.Data;
-using Windows.UI.Xaml.Input;
-using Windows.UI.Xaml.Media;
-using Windows.UI.Xaml.Navigation;
-
-namespace SampleWdpClient.UniversalWindows
-{
- ///
- /// Provides application-specific behavior to supplement the default Application class.
- ///
- sealed partial class App : Application
- {
- ///
- /// Initializes the singleton application object. This is the first line of authored code
- /// executed, and as such is the logical equivalent of main() or WinMain().
- ///
- public App()
- {
- this.InitializeComponent();
- this.Suspending += OnSuspending;
- }
-
- ///
- /// Invoked when the application is launched normally by the end user. Other entry points
- /// will be used such as when the application is launched to open a specific file.
- ///
- /// Details about the launch request and process.
- protected override void OnLaunched(LaunchActivatedEventArgs e)
- {
-#if DEBUG
- if (System.Diagnostics.Debugger.IsAttached)
- {
- this.DebugSettings.EnableFrameRateCounter = true;
- }
-#endif
- Frame rootFrame = Window.Current.Content as Frame;
-
- // Do not repeat app initialization when the Window already has content,
- // just ensure that the window is active
- if (rootFrame == null)
- {
- // Create a Frame to act as the navigation context and navigate to the first page
- rootFrame = new Frame();
-
- rootFrame.NavigationFailed += OnNavigationFailed;
-
- if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
- {
- //TODO: Load state from previously suspended application
- }
-
- // Place the frame in the current Window
- Window.Current.Content = rootFrame;
- }
-
- if (e.PrelaunchActivated == false)
- {
- if (rootFrame.Content == null)
- {
- // When the navigation stack isn't restored navigate to the first page,
- // configuring the new page by passing required information as a navigation
- // parameter
- rootFrame.Navigate(typeof(MainPage), e.Arguments);
- }
- // Ensure the current window is active
- Window.Current.Activate();
- }
- }
-
- ///
- /// Invoked when Navigation to a certain page fails
- ///
- /// The Frame which failed navigation
- /// Details about the navigation failure
- void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
- {
- throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
- }
-
- ///
- /// Invoked when application execution is being suspended. Application state is saved
- /// without knowing whether the application will be terminated or resumed with the contents
- /// of memory still intact.
- ///
- /// The source of the suspend request.
- /// Details about the suspend request.
- private void OnSuspending(object sender, SuspendingEventArgs e)
- {
- var deferral = e.SuspendingOperation.GetDeferral();
- //TODO: Save application state and stop any background activity
- deferral.Complete();
- }
- }
-}
diff --git a/Samples/SampleWdpClient.UniversalWindows/Assets/LockScreenLogo.scale-200.png b/Samples/SampleWdpClient.UniversalWindows/Assets/LockScreenLogo.scale-200.png
deleted file mode 100644
index 735f57ad..00000000
Binary files a/Samples/SampleWdpClient.UniversalWindows/Assets/LockScreenLogo.scale-200.png and /dev/null differ
diff --git a/Samples/SampleWdpClient.UniversalWindows/Assets/SplashScreen.scale-200.png b/Samples/SampleWdpClient.UniversalWindows/Assets/SplashScreen.scale-200.png
deleted file mode 100644
index 023e7f1f..00000000
Binary files a/Samples/SampleWdpClient.UniversalWindows/Assets/SplashScreen.scale-200.png and /dev/null differ
diff --git a/Samples/SampleWdpClient.UniversalWindows/Assets/Square150x150Logo.scale-200.png b/Samples/SampleWdpClient.UniversalWindows/Assets/Square150x150Logo.scale-200.png
deleted file mode 100644
index af49fec1..00000000
Binary files a/Samples/SampleWdpClient.UniversalWindows/Assets/Square150x150Logo.scale-200.png and /dev/null differ
diff --git a/Samples/SampleWdpClient.UniversalWindows/Assets/Square44x44Logo.scale-200.png b/Samples/SampleWdpClient.UniversalWindows/Assets/Square44x44Logo.scale-200.png
deleted file mode 100644
index ce342a2e..00000000
Binary files a/Samples/SampleWdpClient.UniversalWindows/Assets/Square44x44Logo.scale-200.png and /dev/null differ
diff --git a/Samples/SampleWdpClient.UniversalWindows/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/Samples/SampleWdpClient.UniversalWindows/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
deleted file mode 100644
index f6c02ce9..00000000
Binary files a/Samples/SampleWdpClient.UniversalWindows/Assets/Square44x44Logo.targetsize-24_altform-unplated.png and /dev/null differ
diff --git a/Samples/SampleWdpClient.UniversalWindows/Assets/StoreLogo.png b/Samples/SampleWdpClient.UniversalWindows/Assets/StoreLogo.png
deleted file mode 100644
index 7385b56c..00000000
Binary files a/Samples/SampleWdpClient.UniversalWindows/Assets/StoreLogo.png and /dev/null differ
diff --git a/Samples/SampleWdpClient.UniversalWindows/Assets/Wide310x150Logo.scale-200.png b/Samples/SampleWdpClient.UniversalWindows/Assets/Wide310x150Logo.scale-200.png
deleted file mode 100644
index 288995b3..00000000
Binary files a/Samples/SampleWdpClient.UniversalWindows/Assets/Wide310x150Logo.scale-200.png and /dev/null differ
diff --git a/Samples/SampleWdpClient.UniversalWindows/MainPage.xaml b/Samples/SampleWdpClient.UniversalWindows/MainPage.xaml
deleted file mode 100644
index c11d5f82..00000000
--- a/Samples/SampleWdpClient.UniversalWindows/MainPage.xaml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Samples/SampleWdpClient.UniversalWindows/MainPage.xaml.cs b/Samples/SampleWdpClient.UniversalWindows/MainPage.xaml.cs
deleted file mode 100644
index ad8d8d3e..00000000
--- a/Samples/SampleWdpClient.UniversalWindows/MainPage.xaml.cs
+++ /dev/null
@@ -1,399 +0,0 @@
-using System;
-using System.Text;
-using System.Threading.Tasks;
-using Windows.Foundation;
-using Windows.Security.Cryptography.Certificates;
-using Windows.Storage;
-using Windows.Storage.Pickers;
-using Windows.Storage.Streams;
-using Windows.UI.Core;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
-using Microsoft.Tools.WindowsDevicePortal;
-using static Microsoft.Tools.WindowsDevicePortal.DevicePortal;
-
-namespace SampleWdpClient.UniversalWindows
-{
- ///
- /// The main page of the application.
- ///
- public sealed partial class MainPage : Page
- {
- ///
- /// The device portal to which we are connecting.
- ///
- private DevicePortal portal;
-
- private Certificate certificate;
-
- ///
- /// The main page constructor.
- ///
- public MainPage()
- {
- this.InitializeComponent();
- this.EnableDeviceControls(false);
- }
-
- ///
- /// TextChanged handler for the address text box.
- ///
- /// The caller of this method.
- /// The arguments associated with this event.
- private void Address_TextChanged(object sender, TextChangedEventArgs e)
- {
- EnableConnectButton();
- }
-
- ///
- /// If specified in the UI, clears the test output display, otherwise does nothing.
- ///
- private void ClearOutput()
- {
- bool clearOutput = this.clearOutput.IsChecked.HasValue ? this.clearOutput.IsChecked.Value : false;
- if (clearOutput)
- {
- this.commandOutput.Text = string.Empty;
- }
- }
-
- ///
- /// Click handler for the connectToDevice button.
- ///
- /// The caller of this method.
- /// The arguments associated with this event.
- private async void ConnectToDevice_Click(object sender, RoutedEventArgs e)
- {
- this.EnableConnectionControls(false);
- this.EnableDeviceControls(false);
-
- this.ClearOutput();
-
- bool allowUntrusted = this.allowUntrustedCheckbox.IsChecked.Value;
-
- portal = new DevicePortal(
- new DefaultDevicePortalConnection(
- this.address.Text,
- this.username.Text,
- this.password.Password));
-
- StringBuilder sb = new StringBuilder();
-
- sb.Append(this.commandOutput.Text);
- sb.AppendLine("Connecting...");
- this.commandOutput.Text = sb.ToString();
- portal.ConnectionStatus += (portal, connectArgs) =>
- {
- if (connectArgs.Status == DeviceConnectionStatus.Connected)
- {
- sb.Append("Connected to: ");
- sb.AppendLine(portal.Address);
- sb.Append("OS version: ");
- sb.AppendLine(portal.OperatingSystemVersion);
- sb.Append("Device family: ");
- sb.AppendLine(portal.DeviceFamily);
- sb.Append("Platform: ");
- sb.AppendLine(String.Format("{0} ({1})",
- portal.PlatformName,
- portal.Platform.ToString()));
- }
- else if (connectArgs.Status == DeviceConnectionStatus.Failed)
- {
- sb.AppendLine("Failed to connect to the device.");
- sb.AppendLine(connectArgs.Message);
- }
- };
-
- try
- {
- // If the user wants to allow untrusted connections, make a call to GetRootDeviceCertificate
- // with acceptUntrustedCerts set to true. This will enable untrusted connections for the
- // remainder of this session.
- if (allowUntrusted)
- {
- this.certificate = await portal.GetRootDeviceCertificateAsync(true);
- }
- await portal.ConnectAsync(manualCertificate: this.certificate);
- }
- catch (Exception exception)
- {
- sb.AppendLine(exception.Message);
- }
-
- this.commandOutput.Text = sb.ToString();
- EnableDeviceControls(true);
- EnableConnectionControls(true);
- }
-
- ///
- /// Enables or disables the Connect button based on the current state of the
- /// Address, User name and Password fields.
- ///
- private void EnableConnectButton()
- {
- bool enable = (!string.IsNullOrWhiteSpace(this.address.Text) &&
- !string.IsNullOrWhiteSpace(this.username.Text) &&
- !string.IsNullOrWhiteSpace(this.password.Password));
-
- this.connectToDevice.IsEnabled = enable;
- }
-
- ///
- /// Sets the IsEnabled property appropriately for the connection controls.
- ///
- /// True to enable the controls, false to disable them.
- private void EnableConnectionControls(bool enable)
- {
- this.address.IsEnabled = enable;
- this.username.IsEnabled = enable;
- this.password.IsEnabled = enable;
-
- this.connectToDevice.IsEnabled = enable;
- }
-
- ///
- /// Sets the IsEnabled property appropriately for the device command controls.
- ///
- /// True to enable the controls, false to disable them.
- private void EnableDeviceControls(bool enable)
- {
- this.rebootDevice.IsEnabled = enable;
- this.shutdownDevice.IsEnabled = enable;
-
- this.getIPConfig.IsEnabled = enable;
- this.getWiFiInfo.IsEnabled = enable;
- }
-
- ///
- /// Click handler for the getIpConfig button.
- ///
- /// The caller of this method.
- /// The arguments associated with this event.
- private async void GetIPConfig_Click(object sender, RoutedEventArgs e)
- {
- this.ClearOutput();
- this.EnableConnectionControls(false);
- this.EnableDeviceControls(false);
-
- StringBuilder sb = new StringBuilder();
- sb.Append(commandOutput.Text);
- sb.AppendLine("Getting IP configuration...");
- commandOutput.Text = sb.ToString();
-
- try
- {
- IpConfiguration ipconfig = await portal.GetIpConfigAsync();
-
- foreach (NetworkAdapterInfo adapterInfo in ipconfig.Adapters)
- {
- sb.Append(" ");
- sb.AppendLine(adapterInfo.Description);
- sb.Append(" MAC address :");
- sb.AppendLine(adapterInfo.MacAddress);
- foreach (IpAddressInfo address in adapterInfo.IpAddresses)
- {
- sb.Append(" IP address :");
- sb.AppendLine(address.Address);
- }
- sb.Append(" DHCP address :");
- sb.AppendLine(adapterInfo.Dhcp.Address.Address);
- }
- }
- catch (Exception ex)
- {
- sb.AppendLine("Failed to get IP config info.");
- sb.AppendLine(ex.GetType().ToString() + " - " + ex.Message);
- }
-
- commandOutput.Text = sb.ToString();
- EnableDeviceControls(true);
- EnableConnectionControls(true);
- }
-
- ///
- /// Click handler for the getWifiInfo button.
- ///
- /// The caller of this method.
- /// The arguments associated with this event.
- private async void GetWifiInfo_Click(object sender, RoutedEventArgs e)
- {
- this.ClearOutput();
- this.EnableConnectionControls(false);
- this.EnableDeviceControls(false);
-
- StringBuilder sb = new StringBuilder();
-
- sb.Append(commandOutput.Text);
- sb.AppendLine("Getting WiFi interfaces and networks...");
- commandOutput.Text = sb.ToString();
-
- try
- {
- WifiInterfaces wifiInterfaces = await portal.GetWifiInterfacesAsync();
- sb.AppendLine("WiFi Interfaces:");
- foreach (WifiInterface wifiInterface in wifiInterfaces.Interfaces)
- {
- sb.Append(" ");
- sb.AppendLine(wifiInterface.Description);
- sb.Append(" GUID: ");
- sb.AppendLine(wifiInterface.Guid.ToString());
-
- WifiNetworks wifiNetworks = await portal.GetWifiNetworksAsync(wifiInterface.Guid);
- sb.AppendLine(" Networks:");
- foreach (WifiNetworkInfo network in wifiNetworks.AvailableNetworks)
- {
- sb.Append(" SSID: ");
- sb.AppendLine(network.Ssid);
- sb.Append(" Profile name: ");
- sb.AppendLine(network.ProfileName);
- sb.Append(" is connected: ");
- sb.AppendLine(network.IsConnected.ToString());
- sb.Append(" Channel: ");
- sb.AppendLine(network.Channel.ToString());
- sb.Append(" Authentication algorithm: ");
- sb.AppendLine(network.AuthenticationAlgorithm);
- sb.Append(" Signal quality: ");
- sb.AppendLine(network.SignalQuality.ToString());
- }
- };
- }
- catch (Exception ex)
- {
- sb.AppendLine("Failed to get WiFi info.");
- sb.AppendLine(ex.GetType().ToString() + " - " + ex.Message);
- }
-
- commandOutput.Text = sb.ToString();
- EnableDeviceControls(true);
- EnableConnectionControls(true);
- }
-
- ///
- /// PasswordChanged handler for the password text box.
- ///
- /// The caller of this method.
- /// The arguments associated with this event.
- private void Password_PasswordChanged(object sender, RoutedEventArgs e)
- {
- EnableConnectButton();
- }
-
- ///
- /// Click handler for the rebootDevice button.
- ///
- /// The caller of this method.
- /// The arguments associated with this event.
- private async void RebootDevice_Click(object sender, RoutedEventArgs e)
- {
- bool reenableDeviceControls = false;
-
- this.ClearOutput();
- this.EnableConnectionControls(false);
- this.EnableDeviceControls(false);
-
- StringBuilder sb = new StringBuilder();
-
- sb.Append(commandOutput.Text);
- sb.AppendLine("Rebooting the device");
- commandOutput.Text = sb.ToString();
-
- try
- {
- await portal.RebootAsync();
- }
- catch (Exception ex)
- {
- sb.AppendLine("Failed to reboot the device.");
- sb.AppendLine(ex.GetType().ToString() + " - " + ex.Message);
- reenableDeviceControls = true;
- }
-
- commandOutput.Text = sb.ToString();
- EnableDeviceControls(reenableDeviceControls);
- EnableConnectionControls(true);
- }
-
- ///
- /// Click handler for the shutdownDevice button.
- ///
- /// The caller of this method.
- /// The arguments associated with this event.
- private async void ShutdownDevice_Click(object sender, RoutedEventArgs e)
- {
- bool reenableDeviceControls = false;
-
- this.ClearOutput();
- this.EnableConnectionControls(false);
- this.EnableDeviceControls(false);
-
- StringBuilder sb = new StringBuilder();
- sb.Append(commandOutput.Text);
- sb.AppendLine("Shutting down the device");
- commandOutput.Text = sb.ToString();
- try
- {
- await portal.ShutdownAsync();
- }
- catch (Exception ex)
- {
- sb.AppendLine("Failed to shut down the device.");
- sb.AppendLine(ex.GetType().ToString() + " - " + ex.Message);
- reenableDeviceControls = true;
- }
-
- commandOutput.Text = sb.ToString();
- EnableDeviceControls(reenableDeviceControls);
- EnableConnectionControls(true);
- }
-
- ///
- /// TextChanged handler for the username text box.
- ///
- /// The caller of this method.
- /// The arguments associated with this event.
- private void Username_TextChanged(object sender, TextChangedEventArgs e)
- {
- EnableConnectButton();
- }
-
- ///
- /// Loads a cert file for cert validation.
- ///
- /// The caller of this method.
- /// The arguments associated with this event.
- private async void LoadCertificate_Click(object sender, RoutedEventArgs e)
- {
- await LoadCertificate();
- }
-
- ///
- /// Loads a certificates asynchronously (runs on the UI thread).
- ///
- ///
- private async Task LoadCertificate()
- {
- try
- {
- FileOpenPicker filePicker = new FileOpenPicker();
- filePicker.SuggestedStartLocation = PickerLocationId.Downloads;
- filePicker.FileTypeFilter.Add(".cer");
-
- StorageFile file = await filePicker.PickSingleFileAsync();
-
- if (file != null)
- {
- IBuffer cerBlob = await FileIO.ReadBufferAsync(file);
-
- if (cerBlob != null)
- {
- certificate = new Certificate(cerBlob);
- }
- }
- }
- catch (Exception exception)
- {
- this.commandOutput.Text = "Failed to get cert file: " + exception.Message;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Samples/SampleWdpClient.UniversalWindows/Package.appxmanifest b/Samples/SampleWdpClient.UniversalWindows/Package.appxmanifest
deleted file mode 100644
index b615b31e..00000000
--- a/Samples/SampleWdpClient.UniversalWindows/Package.appxmanifest
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
- SampleWdpClient.UniversalWindows
- davidkl
- Assets\StoreLogo.png
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Samples/SampleWdpClient.UniversalWindows/Properties/AssemblyInfo.cs b/Samples/SampleWdpClient.UniversalWindows/Properties/AssemblyInfo.cs
deleted file mode 100644
index 18682017..00000000
--- a/Samples/SampleWdpClient.UniversalWindows/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-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("SampleWdpClient.UniversalWindows")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("SampleWdpClient.UniversalWindows")]
-[assembly: AssemblyCopyright("Copyright © 2016")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
-[assembly: ComVisible(false)]
\ No newline at end of file
diff --git a/Samples/SampleWdpClient.UniversalWindows/Properties/Default.rd.xml b/Samples/SampleWdpClient.UniversalWindows/Properties/Default.rd.xml
deleted file mode 100644
index 80a960ce..00000000
--- a/Samples/SampleWdpClient.UniversalWindows/Properties/Default.rd.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Samples/SampleWdpClient.UniversalWindows/SampleWdpClient.UniversalWindows.csproj b/Samples/SampleWdpClient.UniversalWindows/SampleWdpClient.UniversalWindows.csproj
deleted file mode 100644
index 9066e473..00000000
--- a/Samples/SampleWdpClient.UniversalWindows/SampleWdpClient.UniversalWindows.csproj
+++ /dev/null
@@ -1,146 +0,0 @@
-
-
-
-
- Debug
- x86
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}
- AppContainerExe
- Properties
- SampleWdpClient.UniversalWindows
- SampleWdpClient.UniversalWindows
- en-US
- UAP
- 10.0.10586.0
- 10.0.10240.0
- 14
- 512
- {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- SampleWdpClient.UniversalWindows_TemporaryKey.pfx
-
-
- true
- bin\x86\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
- ;2008
- full
- x86
- false
- prompt
- true
-
-
- bin\x86\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
- true
- ;2008
- pdbonly
- x86
- false
- prompt
- true
- true
-
-
- true
- bin\ARM\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
- ;2008
- full
- ARM
- false
- prompt
- true
-
-
- bin\ARM\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
- true
- ;2008
- pdbonly
- ARM
- false
- prompt
- true
- true
-
-
- true
- bin\x64\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
- ;2008
- full
- x64
- false
- prompt
- true
-
-
- bin\x64\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
- true
- ;2008
- pdbonly
- x64
- false
- prompt
- true
- true
-
-
-
-
-
-
-
- App.xaml
-
-
- MainPage.xaml
-
-
-
-
-
- Designer
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
-
-
- {f2d8b145-a737-494e-aef4-508f9d02e0d7}
- WindowsDevicePortalWrapper.UniversalWindows
-
-
-
- 14.0
-
-
-
-
\ No newline at end of file
diff --git a/Samples/SampleWdpClient.UniversalWindows/Settings.StyleCop b/Samples/SampleWdpClient.UniversalWindows/Settings.StyleCop
deleted file mode 100644
index 6d356bc9..00000000
--- a/Samples/SampleWdpClient.UniversalWindows/Settings.StyleCop
+++ /dev/null
@@ -1,824 +0,0 @@
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- 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.UniversalWindows/project.json b/Samples/SampleWdpClient.UniversalWindows/project.json
deleted file mode 100644
index 92d14561..00000000
--- a/Samples/SampleWdpClient.UniversalWindows/project.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "dependencies": {
- "Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0"
- },
- "frameworks": {
- "uap10.0": {}
- },
- "runtimes": {
- "win10-arm": {},
- "win10-arm-aot": {},
- "win10-x86": {},
- "win10-x86-aot": {},
- "win10-x64": {},
- "win10-x64-aot": {}
- }
-}
\ No newline at end of file
diff --git a/Samples/SampleWdpClient/App.config b/Samples/SampleWdpClient/App.config
deleted file mode 100644
index 88fa4027..00000000
--- a/Samples/SampleWdpClient/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Samples/SampleWdpClient/Properties/AssemblyInfo.cs b/Samples/SampleWdpClient/Properties/AssemblyInfo.cs
deleted file mode 100644
index fc123281..00000000
--- a/Samples/SampleWdpClient/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System.Reflection;
-using System.Resources;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Windows;
-
-// 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("SampleWdpClient")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("SampleWdpClient")]
-[assembly: AssemblyCopyright("Copyright © 2016")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 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)]
-
-//In order to begin building localizable applications, set
-//CultureYouAreCodingWith in your .csproj file
-//inside a . For example, if you are using US english
-//in your source files, set the to en-US. Then uncomment
-//the NeutralResourceLanguage attribute below. Update the "en-US" in
-//the line below to match the UICulture setting in the project file.
-
-//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
-
-
-[assembly: ThemeInfo(
- ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
- //(used if a resource is not found in the page,
- // or application resource dictionaries)
- ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
- //(used if a resource is not found in the page,
- // app, or any theme specific resource dictionaries)
-)]
-
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Samples/SampleWdpClient/Properties/Resources.Designer.cs b/Samples/SampleWdpClient/Properties/Resources.Designer.cs
deleted file mode 100644
index f10a502a..00000000
--- a/Samples/SampleWdpClient/Properties/Resources.Designer.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace SampleWdpClient.Properties
-{
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources()
- {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ((resourceMan == null))
- {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SampleWdpClient.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
- return resourceCulture;
- }
- set
- {
- resourceCulture = value;
- }
- }
- }
-}
diff --git a/Samples/SampleWdpClient/Properties/Resources.resx b/Samples/SampleWdpClient/Properties/Resources.resx
deleted file mode 100644
index af7dbebb..00000000
--- a/Samples/SampleWdpClient/Properties/Resources.resx
+++ /dev/null
@@ -1,117 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
\ No newline at end of file
diff --git a/Samples/SampleWdpClient/Properties/Settings.Designer.cs b/Samples/SampleWdpClient/Properties/Settings.Designer.cs
deleted file mode 100644
index d6be06ca..00000000
--- a/Samples/SampleWdpClient/Properties/Settings.Designer.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace SampleWdpClient.Properties
-{
-
-
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
- internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
- {
-
- private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
-
- public static Settings Default
- {
- get
- {
- return defaultInstance;
- }
- }
- }
-}
diff --git a/Samples/SampleWdpClient/Properties/Settings.settings b/Samples/SampleWdpClient/Properties/Settings.settings
deleted file mode 100644
index 033d7a5e..00000000
--- a/Samples/SampleWdpClient/Properties/Settings.settings
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Samples/SampleWdpClient/SampleWdpClient.csproj b/Samples/SampleWdpClient/SampleWdpClient.csproj
index 6c0705c1..ec227627 100644
--- a/Samples/SampleWdpClient/SampleWdpClient.csproj
+++ b/Samples/SampleWdpClient/SampleWdpClient.csproj
@@ -1,110 +1,14 @@
-
-
+
+
- Debug
- AnyCPU
- {7E0481EB-514A-4292-AD1D-3A3EAF38D359}
- WinExe
- Properties
- SampleWdpClient
- SampleWdpClient
- v4.5.2
- 512
- {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 4
- true
+ netcoreapp3.1
+ winexe
+ true
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
- 4.0
-
-
-
-
-
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
- App.xaml
- Code
-
-
- MainWindow.xaml
- Code
-
-
-
-
- Code
-
-
- True
- True
- Resources.resx
-
-
- True
- Settings.settings
- True
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
- SettingsSingleFileGenerator
- Settings.Designer.cs
-
-
-
-
-
-
+
-
- {6a9e862e-5cda-4a8a-bbc0-56e9ea921e39}
- WindowsDevicePortalWrapper
-
+
-
-
-
\ No newline at end of file
+
+
diff --git a/Samples/SampleWdpClient/Settings.StyleCop b/Samples/SampleWdpClient/Settings.StyleCop
deleted file mode 100644
index 6d356bc9..00000000
--- a/Samples/SampleWdpClient/Settings.StyleCop
+++ /dev/null
@@ -1,824 +0,0 @@
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- 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/App.config b/Samples/XboxWdpDriver/App.config
deleted file mode 100644
index 88fa4027..00000000
--- a/Samples/XboxWdpDriver/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Samples/XboxWdpDriver/CredManager.cs b/Samples/XboxWdpDriver/CredManager.cs
index ff9630aa..2062ca5b 100644
--- a/Samples/XboxWdpDriver/CredManager.cs
+++ b/Samples/XboxWdpDriver/CredManager.cs
@@ -5,8 +5,8 @@
//----------------------------------------------------------------------------------------------
using System;
-using System.Collections.Generic;
-using Windows.Security.Credentials;
+using System.Net;
+using AdysTech.CredentialManager;
namespace XboxWdpDriver
{
@@ -25,14 +25,11 @@ public static void RetrieveStoredCreds(string target, ref string userName, ref s
{
try
{
- PasswordVault vault = new PasswordVault();
// Set the first stored cred as our network creds.
- IReadOnlyList creds = vault.FindAllByResource(target);
- if (creds != null && creds.Count > 0)
+ if (CredentialManager.GetCredentials(target) is NetworkCredential creds)
{
- creds[0].RetrievePassword();
- userName = creds[0].UserName;
- password = creds[0].Password;
+ userName = creds.UserName;
+ password = creds.Password;
}
}
catch (Exception)
@@ -49,22 +46,17 @@ public static void RetrieveStoredCreds(string target, ref string userName, ref s
/// The new password.
public static void UpdateStoredCreds(string target, string userName, string password)
{
- PasswordVault vault = new PasswordVault();
-
try
{
// Remove any existing stored creds for this address and add these ones.
- foreach (var cred in vault.FindAllByResource(target))
- {
- vault.Remove(cred);
- }
+ CredentialManager.RemoveCredentials(target);
}
catch (Exception)
{
// Do nothing. This is expected if no credentials have been previously stored
}
- vault.Add(new PasswordCredential(target, userName, password));
+ CredentialManager.SaveCredentials(target, new NetworkCredential(userName, password));
}
}
}
diff --git a/Samples/XboxWdpDriver/Properties/AssemblyInfo.cs b/Samples/XboxWdpDriver/Properties/AssemblyInfo.cs
deleted file mode 100644
index f73bc911..00000000
--- a/Samples/XboxWdpDriver/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System.Reflection;
-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("XboxWdpDriver")]
-[assembly: AssemblyDescription("Driver app for accessing WDP on an Xbox device.")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("XboxWdpDriver")]
-[assembly: AssemblyCopyright("Copyright © 2016")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 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("664a2974-a463-47bb-95cc-c8b1a454f1bd")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.9.*")]
-[assembly: AssemblyFileVersion("0.9.0.0")]
diff --git a/Samples/XboxWdpDriver/Settings.StyleCop b/Samples/XboxWdpDriver/Settings.StyleCop
deleted file mode 100644
index 97b1afb0..00000000
--- a/Samples/XboxWdpDriver/Settings.StyleCop
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Samples/XboxWdpDriver/XboxWdpDriver.csproj b/Samples/XboxWdpDriver/XboxWdpDriver.csproj
index f4b9e950..95590772 100644
--- a/Samples/XboxWdpDriver/XboxWdpDriver.csproj
+++ b/Samples/XboxWdpDriver/XboxWdpDriver.csproj
@@ -1,88 +1,23 @@
-
-
+
+
- Debug
- AnyCPU
- {1F3CA46B-1E52-418E-A293-23F3FA3BD213}
- Exe
- Properties
- XboxWdpDriver
- XboxWdpDriver
- v4.5.2
- 512
- true
- True
- $(registry:HKEY_LOCAL_MACHINE\Software\CodePlex\StyleCop@TargetsDir)
-
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
- false
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- false
+ netcoreapp3.1
+ exe
+ true
+
-
-
-
-
-
-
-
- C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.UniversalApiContract\2.0.0.0\Windows.Foundation.UniversalApiContract.winmd
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
PreserveNewest
-
-
- {6a9e862e-5cda-4a8a-bbc0-56e9ea921e39}
- WindowsDevicePortalWrapper
-
-
-
-
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/MockDataGenerator/App.config b/WindowsDevicePortalWrapper/MockDataGenerator/App.config
deleted file mode 100644
index 88fa4027..00000000
--- a/WindowsDevicePortalWrapper/MockDataGenerator/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/MockDataGenerator/MockDataGenerator.csproj b/WindowsDevicePortalWrapper/MockDataGenerator/MockDataGenerator.csproj
index bb2dfa81..28dea63c 100644
--- a/WindowsDevicePortalWrapper/MockDataGenerator/MockDataGenerator.csproj
+++ b/WindowsDevicePortalWrapper/MockDataGenerator/MockDataGenerator.csproj
@@ -1,69 +1,13 @@
-
-
+
+
- Debug
- AnyCPU
- {C5AF45CA-C804-42ED-81FD-041B9B7FDBBD}
- Exe
- Properties
- MockDataGenerator
- MockDataGenerator
- v4.5.2
- 512
- true
- True
- $(registry:HKEY_LOCAL_MACHINE\Software\CodePlex\StyleCop@TargetsDir)
+ netcoreapp3.1
+ exe
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
- {6a9e862e-5cda-4a8a-bbc0-56e9ea921e39}
- WindowsDevicePortalWrapper
-
+
-
-
+
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/MockDataGenerator/Properties/AssemblyInfo.cs b/WindowsDevicePortalWrapper/MockDataGenerator/Properties/AssemblyInfo.cs
deleted file mode 100644
index 2357a798..00000000
--- a/WindowsDevicePortalWrapper/MockDataGenerator/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System.Reflection;
-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("MockDataGenerator")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("MockDataGenerator")]
-[assembly: AssemblyCopyright("Copyright © 2016")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 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("c5af45ca-c804-42ed-81fd-041b9b7fdbbd")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/WindowsDevicePortalWrapper/MockDataGenerator/Settings.StyleCop b/WindowsDevicePortalWrapper/MockDataGenerator/Settings.StyleCop
deleted file mode 100644
index fbe07e5c..00000000
--- a/WindowsDevicePortalWrapper/MockDataGenerator/Settings.StyleCop
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/Core/EtwTests.cs b/WindowsDevicePortalWrapper/UnitTestProject/Core/EtwTests.cs
index eb5c3c0f..c4c4378f 100644
--- a/WindowsDevicePortalWrapper/UnitTestProject/Core/EtwTests.cs
+++ b/WindowsDevicePortalWrapper/UnitTestProject/Core/EtwTests.cs
@@ -53,7 +53,7 @@ public void GetEtwProvidersTest()
}
///
- /// Basic test of Get methof for getting ETW events.
+ /// Basic test of Get method for getting ETW events.
///
[TestMethod]
public void GetEtwEventsTest()
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/Device-VersionTests/XboxOne/XboxOne_rs1_xbox_rel_1608.cs b/WindowsDevicePortalWrapper/UnitTestProject/Device-VersionTests/XboxOne/XboxOne_rs1_xbox_rel_1608.cs
index 11174f74..46ea8adb 100644
--- a/WindowsDevicePortalWrapper/UnitTestProject/Device-VersionTests/XboxOne/XboxOne_rs1_xbox_rel_1608.cs
+++ b/WindowsDevicePortalWrapper/UnitTestProject/Device-VersionTests/XboxOne/XboxOne_rs1_xbox_rel_1608.cs
@@ -373,7 +373,7 @@ public void GetSystemPerfWebSocketTest_XboxOne_1608()
public void XboxAppRegisterTest()
{
TestHelpers.MockHttpResponder.AddMockResponse(DevicePortal.RegisterPackageApi, HttpMethods.Post);
- TestHelpers.MockHttpResponder.AddMockResponse(DevicePortal.InstallStateApi, HttpMethods.Post);
+ TestHelpers.MockHttpResponder.AddMockResponse(DevicePortal.InstallStateApi, HttpMethods.Get);
Task registerTask = TestHelpers.Portal.RegisterApplicationAsync("SomeLooseFolder");
registerTask.Wait();
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/MockHttpResponder.cs b/WindowsDevicePortalWrapper/UnitTestProject/MockHttpResponder.cs
index a4a0e6f3..f58cc77e 100644
--- a/WindowsDevicePortalWrapper/UnitTestProject/MockHttpResponder.cs
+++ b/WindowsDevicePortalWrapper/UnitTestProject/MockHttpResponder.cs
@@ -18,7 +18,7 @@ namespace Microsoft.Tools.WindowsDevicePortal.Tests
///
/// Mock implementation of HttpWrapper.
///
- public class MockHttpResponder
+ public class MockHttpResponder : IHttpClient
{
///
/// Dictionary of mock responses from endpoints to the stored response message
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/Properties/AssemblyInfo.cs b/WindowsDevicePortalWrapper/UnitTestProject/Properties/AssemblyInfo.cs
deleted file mode 100644
index e403911e..00000000
--- a/WindowsDevicePortalWrapper/UnitTestProject/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System.Reflection;
-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("UnitTestProject")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("UnitTestProject")]
-[assembly: AssemblyCopyright("Copyright © 2016")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 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("4fc7c762-adbe-4a0a-882d-10771cd8bd55")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/Settings.StyleCop b/WindowsDevicePortalWrapper/UnitTestProject/Settings.StyleCop
deleted file mode 100644
index ca9d8065..00000000
--- a/WindowsDevicePortalWrapper/UnitTestProject/Settings.StyleCop
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/TestHelpers.cs b/WindowsDevicePortalWrapper/UnitTestProject/TestHelpers.cs
index e049d179..9de6f9d9 100644
--- a/WindowsDevicePortalWrapper/UnitTestProject/TestHelpers.cs
+++ b/WindowsDevicePortalWrapper/UnitTestProject/TestHelpers.cs
@@ -45,7 +45,10 @@ public static void EstablishMockConnection(DevicePortalPlatforms platform, strin
HttpMethods.Get);
}
- TestHelpers.Portal = new DevicePortal(new MockDevicePortalConnection());
+ TestHelpers.Portal = new DevicePortal(
+ connection: new MockDevicePortalConnection(),
+ createHttpClient: (_, __) => TestHelpers.MockHttpResponder,
+ webSocketFactory: new MockWebSocketFactory());
Task connectTask = TestHelpers.Portal.ConnectAsync(updateConnection: false);
connectTask.Wait();
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/UnitTestProject.csproj b/WindowsDevicePortalWrapper/UnitTestProject/UnitTestProject.csproj
index a2a04a42..a1b27eef 100644
--- a/WindowsDevicePortalWrapper/UnitTestProject/UnitTestProject.csproj
+++ b/WindowsDevicePortalWrapper/UnitTestProject/UnitTestProject.csproj
@@ -1,440 +1,34 @@
-
+
+
- Debug
- AnyCPU
- {4FC7C762-ADBE-4A0A-882D-10771CD8BD55}
- Library
- Properties
+ netcoreapp3.1
Microsoft.Tools.WindowsDevicePortal.Tests
- UnitTestProject
- v4.5.2
- 512
- {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- 10.0
- $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
- $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
- False
- UnitTest
- True
- $(registry:HKEY_LOCAL_MACHINE\Software\CodePlex\StyleCop@TargetsDir)
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
+
+
+ true
+ ..\WindowsDevicePortalWrapper\DevicePortalWrapperNet.snk
+ false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
- WDPMockImplementations\HttpMultipartFileContent.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
+
PreserveNewest
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
-
-
+
PreserveNewest
-
-
-
-
- False
-
-
- False
-
-
- False
-
-
- False
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/AppDeployment.cs b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/AppDeployment.cs
deleted file mode 100644
index 50b44dfc..00000000
--- a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/AppDeployment.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.Net;
-using System.Net.Http;
-using System.Threading.Tasks;
-using Microsoft.Tools.WindowsDevicePortal.Tests;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// MOCK implementation of App Deployment methods.
- ///
- public partial class DevicePortal
- {
- ///
- /// API for getting installation status.
- ///
- /// The status
- public async Task GetInstallStatusAsync()
- {
- ApplicationInstallStatus status = ApplicationInstallStatus.Completed;
-
- return await Task.FromResult(status);
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/CertificateHandling.cs b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/CertificateHandling.cs
deleted file mode 100644
index e3334524..00000000
--- a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/CertificateHandling.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.Net.Security;
-using System.Security.Cryptography.X509Certificates;
-using System.Threading.Tasks;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// MOCK implementation of device certificate handling methods.
- ///
- public partial class DevicePortal
- {
- ///
- /// Sets the manual certificate.
- ///
- /// Manual certificate
- private void SetManualCertificate(X509Certificate2 cert)
- {
- // Do nothing.
- }
-
- // Disable warning about async method lacking 'await'
-#pragma warning disable 1998
- ///
- /// Gets the root certificate from the device.
- ///
- /// The device certificate.
- private async Task GetRootDeviceCertificate()
- {
- throw new NotSupportedException();
- }
-#pragma warning restore 1998
-
- ///
- /// Validate the server certificate
- ///
- /// The sender object
- /// The server's certificate
- /// The cert chain
- /// Policy Errors
- /// whether the cert passes validation
- private bool ServerCertificateValidation(
- object sender,
- X509Certificate cert,
- X509Chain chain,
- SslPolicyErrors policyErrors)
- {
- return false;
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/WebSocket.cs b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/MockWebSocket.cs
similarity index 82%
rename from WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/WebSocket.cs
rename to WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/MockWebSocket.cs
index 2b433381..be46054e 100644
--- a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/WebSocket.cs
+++ b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/MockWebSocket.cs
@@ -1,5 +1,5 @@
//----------------------------------------------------------------------------------------------
-//
+//
// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
//
//----------------------------------------------------------------------------------------------
@@ -11,15 +11,14 @@
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.Tools.WindowsDevicePortal.Tests;
-namespace Microsoft.Tools.WindowsDevicePortal
+namespace Microsoft.Tools.WindowsDevicePortal.Tests
{
///
/// MOCK implementation of HTTP web socket wrapper
///
/// Return type for the websocket messages.
- internal partial class WebSocket
+ internal class MockWebSocket : WebSocket
{
///
/// Indicates whether the websocket should continue listening for messages.
@@ -31,11 +30,6 @@ internal partial class WebSocket
///
private ManualResetEvent stoppedReceivingMessages = new ManualResetEvent(false);
- ///
- /// The handler used to validate server certificates.
- ///
- private Func
/// The task of closing the websocket connection.
#pragma warning disable 1998
- private async Task StopListeningForMessagesInternalAsync()
+ protected override async Task StopListeningForMessagesInternalAsync()
{
this.keepListeningForMessages = false;
@@ -106,7 +97,7 @@ private async Task StopListeningForMessagesInternalAsync()
/// Once they are received they are parsed and the WebSocketMessageReceived event is raised.
///
/// The task of listening for messages from the websocket.
- private async Task StartListeningForMessagesInternalAsync()
+ protected override async Task StartListeningForMessagesInternalAsync()
{
this.IsListeningForMessages = true;
this.keepListeningForMessages = true;
@@ -153,7 +144,7 @@ private async Task StartListeningForMessagesInternalAsync()
///
/// The message to send.
/// The task of sending the message to the websocket
- private async Task SendMessageInternalAsync(string message)
+ protected override async Task SendMessageInternalAsync(string message)
{
await this.webSocketTask.ConfigureAwait(false);
this.webSocketTask.Wait();
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/MockWebSocketFactory.cs b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/MockWebSocketFactory.cs
new file mode 100644
index 00000000..b71272e2
--- /dev/null
+++ b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/MockWebSocketFactory.cs
@@ -0,0 +1,18 @@
+//----------------------------------------------------------------------------------------------
+//
+// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
+//
+//----------------------------------------------------------------------------------------------
+
+using System;
+using System.Net.Security;
+using System.Security.Cryptography.X509Certificates;
+
+namespace Microsoft.Tools.WindowsDevicePortal.Tests
+{
+ internal class MockWebSocketFactory : IWebSocketFactory
+ {
+ public WebSocket Create(IDevicePortalConnection connection, Func serverCertificateValidationHandler, bool sendStreams = false) =>
+ new MockWebSocket(connection, serverCertificateValidationHandler, sendStreams);
+ }
+}
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestDelete.cs b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestDelete.cs
deleted file mode 100644
index 05019cda..00000000
--- a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestDelete.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.IO;
-using System.Net.Http;
-using System.Threading.Tasks;
-using Microsoft.Tools.WindowsDevicePortal.Tests;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// MOCK implementation of HTTP DeleteAsync
- ///
- public partial class DevicePortal
- {
- ///
- /// Submits the http delete request to the specified uri.
- ///
- /// The uri to which the delete request will be issued.
- /// Task tracking HTTP completion
- private async Task DeleteAsync(Uri uri)
- {
- MemoryStream dataStream = null;
-
- WebRequestHandler requestSettings = new WebRequestHandler();
- requestSettings.UseDefaultCredentials = false;
- requestSettings.Credentials = this.deviceConnection.Credentials;
- requestSettings.ServerCertificateValidationCallback = this.ServerCertificateValidation;
-
- using (HttpClient client = new HttpClient(requestSettings))
- {
- this.ApplyHttpHeaders(client, HttpMethods.Delete);
-
- Task deleteTask = TestHelpers.MockHttpResponder.DeleteAsync(uri);
- await deleteTask.ConfigureAwait(false);
- deleteTask.Wait();
-
- using (HttpResponseMessage response = deleteTask.Result)
- {
- if (!response.IsSuccessStatusCode)
- {
- throw await DevicePortalException.CreateAsync(response);
- }
-
- if (response.Content != null)
- {
- using (HttpContent content = response.Content)
- {
- dataStream = new MemoryStream();
-
- Task copyTask = content.CopyToAsync(dataStream);
- await copyTask.ConfigureAwait(false);
- copyTask.Wait();
-
- // Ensure we return with the stream pointed at the origin.
- dataStream.Position = 0;
- }
- }
- }
- }
-
- return dataStream;
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestGet.cs b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestGet.cs
deleted file mode 100644
index c3e45d45..00000000
--- a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestGet.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.IO;
-using System.Net.Http;
-using System.Threading.Tasks;
-using Microsoft.Tools.WindowsDevicePortal.Tests;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// MOCK implementation of HTTP GetAsync
- ///
- public partial class DevicePortal
- {
- ///
- /// Submits the http get request to the specified uri.
- ///
- /// The uri to which the get request will be issued.
- /// Response data as a stream.
- private async Task GetAsync(
- Uri uri)
- {
- MemoryStream dataStream = null;
-
- WebRequestHandler handler = new WebRequestHandler();
- handler.UseDefaultCredentials = false;
- handler.Credentials = this.deviceConnection.Credentials;
- handler.ServerCertificateValidationCallback = this.ServerCertificateValidation;
-
- using (HttpClient client = new HttpClient(handler))
- {
- this.ApplyHttpHeaders(client, HttpMethods.Get);
-
- Task getTask = TestHelpers.MockHttpResponder.GetAsync(uri);
- await getTask.ConfigureAwait(false);
- getTask.Wait();
-
- using (HttpResponseMessage response = getTask.Result)
- {
- if (!response.IsSuccessStatusCode)
- {
- throw await DevicePortalException.CreateAsync(response);
- }
-
- using (HttpContent content = response.Content)
- {
- dataStream = new MemoryStream();
-
- Task copyTask = content.CopyToAsync(dataStream);
- await copyTask.ConfigureAwait(false);
- copyTask.Wait();
-
- // Ensure we return with the stream pointed at the origin.
- dataStream.Position = 0;
- }
- }
- }
-
- return dataStream;
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPost.cs b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPost.cs
deleted file mode 100644
index d97677da..00000000
--- a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPost.cs
+++ /dev/null
@@ -1,94 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.IO;
-using System.Net.Http;
-using System.Threading.Tasks;
-using Microsoft.Tools.WindowsDevicePortal.Tests;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// MOCK implementation of HTTP PostAsync
- ///
- public partial class DevicePortal
- {
- ///
- /// Submits the http post request to the specified uri.
- ///
- /// The uri to which the post request will be issued.
- /// Optional stream containing data for the request body.
- /// The type of that request body data.
- /// Task tracking the completion of the POST request
- private Task PostAsync(
- Uri uri,
- Stream requestStream = null,
- string requestStreamContentType = null)
- {
- StreamContent requestContent = null;
- if (requestStream != null)
- {
- requestContent = new StreamContent(requestStream);
- requestContent.Headers.Remove(ContentTypeHeaderName);
- requestContent.Headers.TryAddWithoutValidation(ContentTypeHeaderName, requestStreamContentType);
- }
-
- return 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 for the request body.
- /// Task tracking the completion of the POST request
- private async Task PostAsync(
- Uri uri,
- HttpContent requestContent)
- {
- MemoryStream dataStream = null;
- WebRequestHandler requestSettings = new WebRequestHandler();
- requestSettings.UseDefaultCredentials = false;
- requestSettings.Credentials = this.deviceConnection.Credentials;
- requestSettings.ServerCertificateValidationCallback = this.ServerCertificateValidation;
-
- using (HttpClient client = new HttpClient(requestSettings))
- {
- this.ApplyHttpHeaders(client, HttpMethods.Post);
-
- Task postTask = TestHelpers.MockHttpResponder.PostAsync(uri, requestContent);
- await postTask.ConfigureAwait(false);
- postTask.Wait();
-
- using (HttpResponseMessage response = postTask.Result)
- {
- if (!response.IsSuccessStatusCode)
- {
- throw await DevicePortalException.CreateAsync(response);
- }
-
- if (response.Content != null)
- {
- using (HttpContent content = response.Content)
- {
- dataStream = new MemoryStream();
-
- Task copyTask = content.CopyToAsync(dataStream);
- await copyTask.ConfigureAwait(false);
- copyTask.Wait();
-
- // Ensure we return with the stream pointed at the origin.
- dataStream.Position = 0;
- }
- }
- }
- }
-
- return dataStream;
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPut.cs b/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPut.cs
deleted file mode 100644
index 98c38a8d..00000000
--- a/WindowsDevicePortalWrapper/UnitTestProject/WDPMockImplementations/RestPut.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.IO;
-using System.Net.Http;
-using System.Threading.Tasks;
-using Microsoft.Tools.WindowsDevicePortal.Tests;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// MOCK implementation of HTTP PUT
- ///
- public partial class DevicePortal
- {
- ///
- /// Submits the http put request to the specified uri.
- ///
- /// The uri to which the put request will be issued.
- /// The HTTP content comprising the body of the request.
- /// Task tracking the PUT completion.
- private async Task PutAsync(
- Uri uri,
- HttpContent body = null)
- {
- MemoryStream dataStream = null;
-
- WebRequestHandler requestSettings = new WebRequestHandler();
- requestSettings.UseDefaultCredentials = false;
- requestSettings.Credentials = this.deviceConnection.Credentials;
- requestSettings.ServerCertificateValidationCallback = this.ServerCertificateValidation;
-
- using (HttpClient client = new HttpClient(requestSettings))
- {
- this.ApplyHttpHeaders(client, HttpMethods.Put);
-
- // Send the request
- Task putTask = TestHelpers.MockHttpResponder.PutAsync(uri, body);
- await putTask.ConfigureAwait(false);
- putTask.Wait();
-
- using (HttpResponseMessage response = putTask.Result)
- {
- if (!response.IsSuccessStatusCode)
- {
- throw await DevicePortalException.CreateAsync(response);
- }
-
- if (response.Content != null)
- {
- using (HttpContent content = response.Content)
- {
- dataStream = new MemoryStream();
-
- Task copyTask = content.CopyToAsync(dataStream);
- await copyTask.ConfigureAwait(false);
- copyTask.Wait();
-
- // Ensure we return with the stream pointed at the origin.
- dataStream.Position = 0;
- }
- }
- }
- }
-
- return dataStream;
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppDeployment.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppDeployment.cs
deleted file mode 100644
index 93a9a3de..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppDeployment.cs
+++ /dev/null
@@ -1,409 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-#if !WINDOWS_UWP
-using System.Net;
-using System.Net.Http;
-#endif // !WINDOWS_UWP
-using System.Runtime.Serialization;
-using System.Text;
-using System.Threading.Tasks;
-#if WINDOWS_UWP
-using Windows.Foundation;
-using Windows.Security.Credentials;
-using Windows.Storage.Streams;
-using Windows.Web.Http;
-using Windows.Web.Http.Filters;
-using Windows.Web.Http.Headers;
-#endif
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// Wrappers for App Deployment methods.
- ///
- public partial class DevicePortal
- {
- ///
- /// API to retrieve list of installed packages.
- ///
- public static readonly string InstalledPackagesApi = "api/app/packagemanager/packages";
-
- ///
- /// Install state API.
- ///
- public static readonly string InstallStateApi = "api/app/packagemanager/state";
-
- ///
- /// API for package management.
- ///
- public static readonly string PackageManagerApi = "api/app/packagemanager/package";
-
- ///
- /// App Install Status handler.
- ///
- public event ApplicationInstallStatusEventHandler AppInstallStatus;
-
- ///
- /// Gets the collection of applications installed on the device.
- ///
- /// AppPackages object containing the list of installed application packages.
- public async Task GetInstalledAppPackagesAsync()
- {
- return await this.GetAsync(InstalledPackagesApi);
- }
-
- ///
- /// Installs an application
- ///
- /// Friendly name (ex: Hello World) of the application. If this parameter is not provided, the name of the package is assumed to be the app name.
- /// Full name of the application package file.
- /// List containing the full names of any required dependency files.
- /// Full name of the optional certificate file.
- /// How frequently we should check the installation state.
- /// Operation timeout.
- /// Indicate whether or not the previous app version should be uninstalled prior to installing.
- /// InstallApplication sends ApplicationInstallStatus events to indicate the current progress in the installation process.
- /// Some applications may opt to not register for the AppInstallStatus event and await on InstallApplication.
- /// Task for tracking completion of install initialization.
- public async Task InstallApplicationAsync(
- string appName,
- string packageFileName,
- List dependencyFileNames,
- string certificateFileName = null,
- short stateCheckIntervalMs = 500,
- short timeoutInMinutes = 15,
- bool uninstallPreviousVersion = true)
- {
- string installPhaseDescription = string.Empty;
-
- try
- {
- FileInfo packageFile = new FileInfo(packageFileName);
-
- // If appName was not provided, use the package file name
- if (string.IsNullOrEmpty(appName))
- {
- appName = packageFile.Name;
- }
-
- // Uninstall the application's previous version, if one exists.
- if (uninstallPreviousVersion)
- {
- installPhaseDescription = string.Format("Uninstalling any previous version of {0}", appName);
- this.SendAppInstallStatus(
- ApplicationInstallStatus.InProgress,
- ApplicationInstallPhase.UninstallingPreviousVersion,
- installPhaseDescription);
- AppPackages installedApps = await this.GetInstalledAppPackagesAsync();
- foreach (PackageInfo package in installedApps.Packages)
- {
- if (package.Name == appName)
- {
- await this.UninstallApplicationAsync(package.FullName);
- break;
- }
- }
- }
-
- // Create the API endpoint and generate a unique boundary string.
- Uri uri;
- string boundaryString;
- this.CreateAppInstallEndpointAndBoundaryString(
- packageFile.Name,
- out uri,
- out boundaryString);
-
- installPhaseDescription = string.Format("Copying: {0}", packageFile.Name);
- this.SendAppInstallStatus(
- ApplicationInstallStatus.InProgress,
- ApplicationInstallPhase.CopyingFile,
- installPhaseDescription);
-
- var content = new HttpMultipartFileContent();
- content.Add(packageFile.FullName);
- content.AddRange(dependencyFileNames);
- content.Add(certificateFileName);
- await this.PostAsync(uri, content);
-
- // Poll the status until complete.
- ApplicationInstallStatus status = ApplicationInstallStatus.InProgress;
- do
- {
- installPhaseDescription = string.Format("Installing {0}", appName);
- this.SendAppInstallStatus(
- ApplicationInstallStatus.InProgress,
- ApplicationInstallPhase.Installing,
- installPhaseDescription);
-
- await Task.Delay(TimeSpan.FromMilliseconds(stateCheckIntervalMs));
-
- status = await this.GetInstallStatusAsync().ConfigureAwait(false);
- }
- while (status == ApplicationInstallStatus.InProgress);
-
- installPhaseDescription = string.Format("{0} installed successfully", appName);
- this.SendAppInstallStatus(
- ApplicationInstallStatus.Completed,
- ApplicationInstallPhase.Idle,
- installPhaseDescription);
- }
- catch (Exception e)
- {
- DevicePortalException dpe = e as DevicePortalException;
-
- if (dpe != null)
- {
- this.SendAppInstallStatus(
- ApplicationInstallStatus.Failed,
- ApplicationInstallPhase.Idle,
- string.Format("Failed to install {0}: {1}", appName, dpe.Reason));
- }
- else
- {
- this.SendAppInstallStatus(
- ApplicationInstallStatus.Failed,
- ApplicationInstallPhase.Idle,
- string.Format("Failed to install {0}: {1}", appName, installPhaseDescription));
- }
- }
- }
-
- ///
- /// Uninstalls the specified application.
- ///
- /// The name of the application package to uninstall.
- /// Task tracking the uninstall operation.
- public async Task UninstallApplicationAsync(string packageName)
- {
- await this.DeleteAsync(
- PackageManagerApi,
- //// NOTE: When uninstalling an app package, the package name is not Hex64 encoded.
- string.Format("package={0}", packageName));
- }
-
- ///
- /// Builds the application installation Uri and generates a unique boundary string for the multipart form data.
- ///
- /// The name of the application package.
- /// The endpoint for the install request.
- /// Unique string used to separate the parts of the multipart form data.
- private void CreateAppInstallEndpointAndBoundaryString(
- string packageName,
- out Uri uri,
- out string boundaryString)
- {
- uri = Utilities.BuildEndpoint(
- this.deviceConnection.Connection,
- PackageManagerApi,
- string.Format("package={0}", packageName));
-
- boundaryString = Guid.NewGuid().ToString();
- }
-
- ///
- /// Sends application install status.
- ///
- /// Status of the installation.
- /// Current installation phase (ex: Uninstalling previous version)
- /// Optional error message describing the install status.
- private void SendAppInstallStatus(
- ApplicationInstallStatus status,
- ApplicationInstallPhase phase,
- string message = "")
- {
- this.AppInstallStatus?.Invoke(
- this,
- new ApplicationInstallStatusEventArgs(status, phase, message));
- }
-
- #region Data contract
- ///
- /// Object representing a list of Application Packages
- ///
- [DataContract]
- public class AppPackages
- {
- ///
- /// Gets a list of the packages
- ///
- [DataMember(Name = "InstalledPackages")]
- public List Packages { get; private set; }
-
- ///
- /// Presents a user readable representation of a list of AppPackages
- ///
- /// User readable list of AppPackages.
- public override string ToString()
- {
- string output = "Packages:\n";
- foreach (PackageInfo package in this.Packages)
- {
- output += package;
- }
-
- return output;
- }
- }
-
- ///
- /// Object representing the install state
- ///
- [DataContract]
- public class InstallState
- {
- ///
- /// Gets install state code
- ///
- [DataMember(Name = "Code")]
- public int Code { get; private set; }
-
- ///
- /// Gets message text
- ///
- [DataMember(Name = "CodeText")]
- public string CodeText { get; private set; }
-
- ///
- /// Gets reason for state
- ///
- [DataMember(Name = "Reason")]
- public string Reason { get; private set; }
-
- ///
- /// Gets a value indicating whether this was successful
- ///
- [DataMember(Name = "Success")]
- public bool WasSuccessful { get; private set; }
- }
-
- ///
- /// object representing the package information
- ///
- [DataContract]
- public class PackageInfo
- {
- ///
- /// Gets package name
- ///
- [DataMember(Name = "Name")]
- public string Name { get; private set; }
-
- ///
- /// Gets package family name
- ///
- [DataMember(Name = "PackageFamilyName")]
- public string FamilyName { get; private set; }
-
- ///
- /// Gets package full name
- ///
- [DataMember(Name = "PackageFullName")]
- public string FullName { get; private set; }
-
- ///
- /// Gets package relative Id
- ///
- [DataMember(Name = "PackageRelativeId")]
- public string AppId { get; private set; }
-
- ///
- /// Gets package publisher
- ///
- [DataMember(Name = "Publisher")]
- public string Publisher { get; private set; }
-
- ///
- /// Gets package version
- ///
- [DataMember(Name = "Version")]
- public PackageVersion Version { get; private set; }
-
- ///
- /// Gets package origin, a measure of how the app was installed.
- /// PackageOrigin_Unknown = 0,
- /// PackageOrigin_Unsigned = 1,
- /// PackageOrigin_Inbox = 2,
- /// PackageOrigin_Store = 3,
- /// PackageOrigin_DeveloperUnsigned = 4,
- /// PackageOrigin_DeveloperSigned = 5,
- /// PackageOrigin_LineOfBusiness = 6
- ///
- [DataMember(Name = "PackageOrigin")]
- public int PackageOrigin { get; private set; }
-
- ///
- /// Helper method to determine if the app was sideloaded and therefore can be used with e.g. GetFolderContentsAsync
- ///
- /// True if the package is sideloaded.
- public bool IsSideloaded()
- {
- return this.PackageOrigin == 4 || this.PackageOrigin == 5;
- }
-
- ///
- /// Get a string representation of the package
- ///
- /// String representation
- public override string ToString()
- {
- return string.Format("\t{0}\n\t\t{1}\n", this.FullName, this.AppId);
- }
- }
-
- ///
- /// Object representing a package version
- ///
- [DataContract]
- public class PackageVersion
- {
- ///
- /// Gets version build
- ///
- [DataMember(Name = "Build")]
- public int Build { get; private set; }
-
- ///
- /// Gets package Major number
- ///
- [DataMember(Name = "Major")]
- public int Major { get; private set; }
-
- ///
- /// Gets package minor number
- ///
- [DataMember(Name = "Minor")]
- public int Minor { get; private set; }
-
- ///
- /// Gets package revision
- ///
- [DataMember(Name = "Revision")]
- public int Revision { get; private set; }
-
- ///
- /// Gets package version
- ///
- public Version Version
- {
- get { return new Version(this.Major, this.Minor, this.Build, this.Revision); }
- }
-
- ///
- /// Get a string representation of a version
- ///
- /// String representation
- public override string ToString()
- {
- return Version.ToString();
- }
- }
- #endregion // Data contract
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/ResourceManager.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/ResourceManager.cs
deleted file mode 100644
index 35fefa28..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/ResourceManager.cs
+++ /dev/null
@@ -1,247 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System.Collections.Generic;
-using System.Runtime.Serialization;
-using System.Threading.Tasks;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// Wrappers for Resource Manager methods.
- ///
- public partial class DevicePortal
- {
- ///
- /// API for getting processes currently running on the device.
- ///
- private static readonly string ProcessesApi = "/api/resourcemanager/processes";
-
-#if !WINDOWS_UWP
- ///
- /// Web socket to get the processes currently running on the device.
- ///
- private WebSocket deviceProcessesWebSocket;
-
- ///
- /// Gets or sets the processes message received handler.
- ///
- public WebSocketMessageReceivedEventHandler ProcessesMessageReceived
- {
- get;
- set;
- }
-
- ///
- /// Starts listening for the running processes on the device with them being returned via the ProcessesMessageReceived event handler.
- ///
- /// Task for connecting to the websocket but not for listening to it.
- public async Task StartListeningForProcesses()
- {
- if (this.deviceProcessesWebSocket == null)
- {
- this.deviceProcessesWebSocket = new WebSocket(this.deviceConnection, this.ServerCertificateValidation);
-
- this.deviceProcessesWebSocket.WebSocketMessageReceived += this.ProcessesReceivedHandler;
- }
- else
- {
- if (this.deviceProcessesWebSocket.IsListeningForMessages)
- {
- return;
- }
- }
-
- await this.deviceProcessesWebSocket.OpenConnection(ProcessesApi);
-
- // Do not await on the actual listening.
- Task listenTask = this.deviceProcessesWebSocket.StartListeningForMessages();
- }
-
- ///
- /// Stop listening for the running processes on the device.
- ///
- /// Task for stop listening for processes and disconnecting from the websocket .
- public async Task StopListeningForProcesses()
- {
- if (this.deviceProcessesWebSocket == null || !this.deviceProcessesWebSocket.IsListeningForMessages)
- {
- return;
- }
-
- await this.deviceProcessesWebSocket.CloseConnection();
- }
-
- ///
- /// Handler for the processes received event that passes the event to the ProcessesMessageReceived handler.
- ///
- /// The object sending the event.
- /// The event data.
- private void ProcessesReceivedHandler(
- object sender,
- WebSocketMessageReceivedEventArgs args)
- {
- if (args.Message != null)
- {
- this.ProcessesMessageReceived?.Invoke(
- this,
- args);
- }
- }
-#endif // !WINDOWS_UWP
-
- #region Data contract
-
- ///
- /// Object representing a list of processes
- ///
- [DataContract]
- public class DeviceProcesses
- {
- ///
- /// Gets or sets a list of the packages
- ///
- [DataMember(Name = "Processes")]
- public List Processes { get; set; }
- }
-
- ///
- /// Object representing the process information
- ///
- [DataContract]
- public class ProcessInfo
- {
- ///
- /// Gets or sets CPU usage
- ///
- [DataMember(Name = "CPUUsage")]
- public double CPUUsage { get; set; }
-
- ///
- /// Gets or sets image name
- ///
- [DataMember(Name = "ImageName")]
- public string ImageName { get; set; }
-
- ///
- /// Gets or sets page file usage
- ///
- [DataMember(Name = "PageFileUsage")]
- public double PageFileUsage { get; set; }
-
- ///
- /// Gets or sets package working set
- ///
- [DataMember(Name = "PrivateWorkingSet")]
- public double PrivateWorkingSet { get; set; }
-
- ///
- /// Gets or sets process id
- ///
- [DataMember(Name = "ProcessId")]
- public uint ProcessId { get; set; }
-
- ///
- /// Gets or sets session id
- ///
- [DataMember(Name = "SessionId")]
- public uint SessionId { get; set; }
-
- ///
- /// Gets or sets total commit
- ///
- [DataMember(Name = "TotalCommit")]
- public double TotalCommit { get; set; }
-
- ///
- /// Gets or sets user name
- ///
- [DataMember(Name = "UserName")]
- public string UserName { get; set; }
-
- ///
- /// Gets or sets virtual size
- ///
- [DataMember(Name = "VirtualSize")]
- public double VirtualSize { get; set; }
-
- ///
- /// Gets or sets working set size
- ///
- [DataMember(Name = "WorkingSetSize")]
- public double WorkingSetSize { get; set; }
-
- ///
- /// Gets or sets a value indicating whether or not the process is running
- ///
- [DataMember(Name = "IsRunning")]
- public bool IsRunning { get; set; }
-
- ///
- /// Gets or sets package full name
- ///
- [DataMember(Name = "PackageFullName")]
- public string PackageFullName { get; set; }
-
- ///
- /// Gets or sets app name
- ///
- [DataMember(Name = "AppName")]
- public string AppName { get; set; }
-
- ///
- /// Gets or sets publisher
- ///
- [DataMember(Name = "Publisher")]
- public string Publisher { get; set; }
-
- ///
- /// Gets or sets version
- ///
- [DataMember(Name = "Version")]
- public ProcessVersion Version { get; set; }
-
- ///
- /// Gets or sets a value indicating whether or not the package is a XAP package
- ///
- [DataMember(Name = "IsXAP")]
- public bool IsXAP { get; set; }
- }
-
- ///
- /// Object representing the process version.
- ///
- [DataContract]
- public class ProcessVersion
- {
- ///
- /// Gets or sets the major version number
- ///
- [DataMember(Name = "Major")]
- public uint Major { get; set; }
-
- ///
- /// Gets or sets the minor version number
- ///
- [DataMember(Name = "Minor")]
- public uint Minor { get; set; }
-
- ///
- /// Gets or sets the build number
- ///
- [DataMember(Name = "Build")]
- public uint Build { get; set; }
-
- ///
- /// Gets or sets the revision number
- ///
- [DataMember(Name = "Revision")]
- public uint Revision { get; set; }
- }
-
- #endregion
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RequestHelpers.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RequestHelpers.cs
deleted file mode 100644
index 14c44151..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RequestHelpers.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System.IO;
-using System.Runtime.Serialization;
-using System.Text;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// Methods for working with Http requests.
- ///
- public partial class DevicePortal
- {
- ///
- /// Copies a file to the specified stream and prepends the necessary content information
- /// required to be part of a multipart form data request.
- ///
- /// The file to be copied.
- /// The stream to which the file will be copied.
- private static void CopyFileToRequestStream(
- FileInfo file,
- Stream stream)
- {
- byte[] data;
- string contentDisposition = string.Format("Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n", file.Name, file.Name);
- string contentType = "Content-Type: application/octet-stream\r\n\r\n";
-
- data = Encoding.ASCII.GetBytes(contentDisposition);
- stream.Write(data, 0, data.Length);
-
- data = Encoding.ASCII.GetBytes(contentType);
- stream.Write(data, 0, data.Length);
-
- using (FileStream fs = File.OpenRead(file.FullName))
- {
- fs.CopyTo(stream);
- }
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RestDelete.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RestDelete.cs
deleted file mode 100644
index 71045e74..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RestDelete.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.IO;
-using System.Runtime.Serialization.Json;
-using System.Threading.Tasks;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// HTTP DELETE Wrapper
- ///
- public partial class DevicePortal
- {
- ///
- /// Calls the specified API with the provided payload. This signature leaves
- /// off the optional response so callers who don't need a response body
- /// don't need to specify a type for it.
- ///
- /// The relative portion of the uri path that specifies the API to call.
- /// The query string portion of the uri path that provides the parameterized data.
- /// Task tracking the HTTP completion.
- public async Task DeleteAsync(
- string apiPath,
- string payload = null)
- {
- await this.DeleteAsync(apiPath, payload);
- }
-
- ///
- /// Calls the specified API with the provided payload.
- ///
- /// The type of the data for the HTTP response body (if present).
- /// The relative portion of the uri path that specifies the API to call.
- /// The query string portion of the uri path that provides the parameterized data.
- /// Task tracking the HTTP completion.
- public async Task DeleteAsync(
- string apiPath,
- string payload = null) where T : new()
- {
- Uri uri = Utilities.BuildEndpoint(
- this.deviceConnection.Connection,
- apiPath,
- payload);
-
- return ReadJsonStream(await this.DeleteAsync(uri));
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RestGet.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RestGet.cs
deleted file mode 100644
index 85aeb315..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RestGet.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// 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.Http;
-using System.Net.Http.Headers;
-using System.Runtime.Serialization.Json;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// HTTP GET Wrapper
- ///
- public partial class DevicePortal
- {
- ///
- /// Calls the specified API with the provided payload.
- ///
- /// Return type for the GET call
- /// The relative portion of the uri path that specifies the API to call.
- /// The query string portion of the uri path that provides the parameterized data.
- /// An object of the specified type containing the data returned by the request.
- public async Task GetAsync(
- string apiPath,
- string payload = null) where T : new()
- {
- Uri uri = Utilities.BuildEndpoint(
- this.deviceConnection.Connection,
- apiPath,
- payload);
-
- return ReadJsonStream(await this.GetAsync(uri).ConfigureAwait(false));
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RestPost.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RestPost.cs
deleted file mode 100644
index 75a7ee13..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RestPost.cs
+++ /dev/null
@@ -1,83 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// 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.Runtime.Serialization.Json;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// HTTP POST Wrapper
- ///
- public partial class DevicePortal
- {
- ///
- /// Calls the specified API with the provided body. This signature leaves
- /// off the optional response so callers who don't need a response body
- /// don't need to specify a type for it.
- ///
- /// The relative portion of the uri path that specifies the API to call.
- /// List of files that we want to include in the post request.
- /// The query string portion of the uri path that provides the parameterized data.
- /// Task tracking the POST completion.
- public async Task PostAsync(
- string apiPath,
- List files,
- string payload = null)
- {
- Uri uri = Utilities.BuildEndpoint(
- this.deviceConnection.Connection,
- apiPath,
- payload);
-
- var content = new HttpMultipartFileContent();
- content.AddRange(files);
- await this.PostAsync(uri, content);
- }
-
- ///
- /// Calls the specified API with the provided body. This signature leaves
- /// off the optional response so callers who don't need a response body
- /// don't need to specify a type for it.
- ///
- /// The relative portion of the uri path that specifies the API to call.
- /// The query string portion of the uri path that provides the parameterized data.
- /// Task tracking the POST completion.
- public async Task PostAsync(
- string apiPath,
- string payload = null)
- {
- await this.PostAsync(apiPath, payload);
- }
-
- ///
- /// Calls the specified API with the provided payload.
- ///
- /// The type of the data for the HTTP response body (if present).
- /// The relative portion of the uri path that specifies the API to call.
- /// The query string portion of the uri path that provides the parameterized data.
- /// Optional stream containing data for the request body.
- /// The type of that request body data.
- /// Task tracking the POST completion.
- public async Task PostAsync(
- string apiPath,
- string payload = null,
- Stream requestStream = null,
- string requestStreamContentType = null) where T : new()
- {
- Uri uri = Utilities.BuildEndpoint(
- this.deviceConnection.Connection,
- apiPath,
- payload);
-
- return ReadJsonStream(await this.PostAsync(uri, requestStream, requestStreamContentType));
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RestPut.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RestPut.cs
deleted file mode 100644
index b9759cfa..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/RestPut.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.IO;
-#if !WINDOWS_UWP
-using System.Net.Http;
-using System.Net.Http.Headers;
-#endif // !WINDOWS_UWP
-using System.Runtime.Serialization.Json;
-using System.Threading.Tasks;
-#if WINDOWS_UWP
-using Windows.Foundation;
-using Windows.Networking;
-using Windows.Security.Credentials;
-using Windows.Storage.Streams;
-using Windows.Web.Http;
-using Windows.Web.Http.Filters;
-using Windows.Web.Http.Headers;
-#endif // WINDOWS_UWP
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// HTTP PUT Wrapper
- ///
- public partial class DevicePortal
- {
- ///
- /// Calls the specified API with the provided body. This signature leaves
- /// off the optional response so callers who don't need a response body
- /// don't need to specify a type for it, which also would force them
- /// to explicitly declare their bodyData type instead of letting it
- /// be implied implicitly.
- ///
- /// The type of the data for the HTTP request body.
- /// The relative portion of the uri path that specifies the API to call.
- /// The data to be used for the HTTP request body.
- /// The query string portion of the uri path that provides the parameterized data.
- /// Task tracking the PUT completion.
- public async Task PutAsync(
- string apiPath,
- K bodyData,
- string payload = null) where K : class
- {
- await this.PutAsync(apiPath, bodyData, payload);
- }
-
- ///
- /// Calls the specified API with the provided body.
- ///
- /// The type of the data for the HTTP response body (if present).
- /// The type of the data for the HTTP request body.
- /// The relative portion of the uri path that specifies the API to call.
- /// The data to be used for the HTTP request body.
- /// The query string portion of the uri path that provides the parameterized data.
- /// Task tracking the PUT completion, optional response body.
- public async Task PutAsync(
- string apiPath,
- K bodyData = null,
- string payload = null) where T : new()
- where K : class
- {
- Uri uri = Utilities.BuildEndpoint(
- this.deviceConnection.Connection,
- apiPath,
- payload);
-
-#if WINDOWS_UWP
- HttpStreamContent streamContent = null;
-#else
- StreamContent streamContent = null;
-#endif // WINDOWS_UWP
-
- if (bodyData != null)
- {
- // Serialize the body to a JSON stream
- DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(K));
- Stream stream = new MemoryStream();
- serializer.WriteObject(stream, bodyData);
-
- stream.Seek(0, SeekOrigin.Begin);
-#if WINDOWS_UWP
- streamContent = new HttpStreamContent(stream.AsInputStream());
- streamContent.Headers.ContentType = new HttpMediaTypeHeaderValue("application/json");
-#else
- streamContent = new StreamContent(stream);
- streamContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
-#endif // WINDOWS_UWP
- }
-
- return ReadJsonStream(await this.PutAsync(uri, streamContent));
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/WebSocket.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/WebSocket.cs
deleted file mode 100644
index 8328e0c1..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/WebSocket.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.Diagnostics;
-using System.IO;
-using System.Runtime.Serialization;
-using System.Runtime.Serialization.Json;
-using System.Threading.Tasks;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// Internal Web socket message received event handler
- ///
- /// sender object
- /// Web socket message received args
- /// Return type for the websocket messages.
- internal delegate void WebSocketMessageReceivedEventInternalHandler(WebSocket sender, WebSocketMessageReceivedEventArgs args);
-
- ///
- /// Internal Web socket stream received event handler
- ///
- /// sender object
- /// Web socket message received args
- /// Return type for the websocket.
- internal delegate void WebSocketStreamReceivedEventInternalHandler(WebSocket sender, WebSocketMessageReceivedEventArgs args);
-
- ///
- /// HTTP Websocket Wrapper
- ///
- /// Return type for the websocket messages.
- internal partial class WebSocket
- {
- ///
- /// The device that the is connected to.
- ///
- private IDevicePortalConnection deviceConnection;
-
- ///
- /// Indicates whether the web socket should send streams instead of parsed objects
- ///
- private bool sendStreams = false;
-
- ///
- /// Gets or sets the message received handler.
- ///
- public event WebSocketMessageReceivedEventInternalHandler WebSocketMessageReceived;
-
- ///
- /// Gets or sets the stream received handler.
- ///
- public event WebSocketStreamReceivedEventInternalHandler WebSocketStreamReceived;
-
- ///
- /// Gets a value indicating whether the web socket is connected.
- ///
- public bool IsConnected
- {
- get;
- private set;
- }
-
- ///
- /// Gets a value indicating whether the web socket is listening for messages.
- ///
- public bool IsListeningForMessages
- {
- get;
- private set;
- }
-
- ///
- /// Initialize a connection to the websocket.
- ///
- /// The relative portion of the uri path that specifies the API to call.
- /// The query string portion of the uri path that provides the parameterized data.
- /// The task of opening the websocket connection.
- internal async Task ConnectAsync(string apiPath, string payload = null)
- {
- if (this.IsConnected)
- {
- return;
- }
-
- Uri uri = Utilities.BuildEndpoint(
- this.deviceConnection.WebSocketConnection,
- apiPath,
- payload);
- await this.ConnectInternalAsync(uri);
- }
-
- ///
- /// Closes the connection to the websocket and stop listening for messages.
- ///
- /// The task of closing the websocket connection.
- internal async Task CloseAsync()
- {
- if (this.IsConnected)
- {
- if (this.IsListeningForMessages)
- {
- await this.StopListeningForMessagesInternalAsync();
- }
-
- await this.CloseInternalAsync();
- }
- }
-
- ///
- /// Starts listening for messages from the websocket. Once they are received they are parsed and the WebSocketMessageReceived event is raised.
- ///
- /// The task of listening for messages from the websocket.
- internal async Task ReceiveMessagesAsync()
- {
- if (this.IsConnected && !this.IsListeningForMessages)
- {
- await this.StartListeningForMessagesInternalAsync();
- }
- }
-
- ///
- /// Sends a message to the server.
- ///
- /// The message to send.
- /// The task of sending a message to the websocket.
- internal async Task SendMessageAsync(string message)
- {
- if (this.IsConnected)
- {
- await this.SendMessageInternalAsync(message);
- }
- }
-
- ///
- /// Converts received stream to a parsed object and passes it to
- /// the WebSocketMessageReceived handler. The sendstreams property can be used to
- /// override this and send the instead via the WebSocketStreamReceived handler.
- ///
- /// The received stream.
- private void ConvertStreamToMessage(Stream stream)
- {
- if (stream != null && stream.Length != 0)
- {
- if (this.sendStreams)
- {
- this.WebSocketStreamReceived?.Invoke(
- this,
- new WebSocketMessageReceivedEventArgs(stream));
- }
- else
- {
- DataContractJsonSerializerSettings settings = new DataContractJsonSerializerSettings()
- {
- UseSimpleDictionaryFormat = true
- };
-
- T message = DevicePortal.ReadJsonStream(stream, settings);
-
- this.WebSocketMessageReceived?.Invoke(
- this,
- new WebSocketMessageReceivedEventArgs(message));
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Settings.StyleCop b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Settings.StyleCop
deleted file mode 100644
index bb05f99b..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Settings.StyleCop
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/WindowsDevicePortalWrapper.Shared.projitems b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/WindowsDevicePortalWrapper.Shared.projitems
deleted file mode 100644
index 488cd40d..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/WindowsDevicePortalWrapper.Shared.projitems
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-
- $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
- true
- af72a46d-5d30-4fb4-8d3e-b516ed19f9a4
-
-
- Microsoft.Tools.WindowsDevicePortal
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/WindowsDevicePortalWrapper.Shared.shproj b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/WindowsDevicePortalWrapper.Shared.shproj
deleted file mode 100644
index 974fdeed..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/WindowsDevicePortalWrapper.Shared.shproj
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
- af72a46d-5d30-4fb4-8d3e-b516ed19f9a4
- 14.0
- True
- $(registry:HKEY_LOCAL_MACHINE\Software\CodePlex\StyleCop@TargetsDir)
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/CertificateHandling.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/CertificateHandling.cs
deleted file mode 100644
index 5c140920..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/CertificateHandling.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using Windows.Foundation;
-using Windows.Security.Cryptography.Certificates;
-using Windows.Storage.Streams;
-using Windows.Web.Http;
-using Windows.Web.Http.Filters;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// Universal Windows Platform implementation of device certificate handling methods.
- ///
- public partial class DevicePortal
- {
- ///
- /// Gets the root certificate from the device.
- ///
- /// Whether or not we should accept untrusted certificates.
- /// The device certificate.
-#pragma warning disable 1998
- public async Task GetRootDeviceCertificateAsync(bool acceptUntrustedCerts = false)
- {
- Certificate certificate = null;
-
- Uri uri = Utilities.BuildEndpoint(this.deviceConnection.Connection, RootCertificateEndpoint);
-
- HttpBaseProtocolFilter requestSettings = new HttpBaseProtocolFilter();
- requestSettings.AllowUI = false;
-
- if (acceptUntrustedCerts)
- {
- requestSettings.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
- }
-
- using (HttpClient client = new HttpClient(requestSettings))
- {
- this.ApplyHttpHeaders(client, HttpMethods.Get);
- using (HttpResponseMessage response = await client.GetAsync(uri))
- {
- using (IHttpContent messageContent = response.Content)
- {
- certificate = new Certificate(await messageContent.ReadAsBufferAsync());
- }
- }
- }
-
- return certificate;
- }
-#pragma warning restore 1998
-
- ///
- /// Sets the manual certificate.
- ///
- /// Manual certificate
- private void SetManualCertificate(Certificate cert)
- {
- CertificateStore store = CertificateStores.TrustedRootCertificationAuthorities;
- store.Add(cert);
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/Core/AppDeployment.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/Core/AppDeployment.cs
deleted file mode 100644
index 2a1ec603..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/Core/AppDeployment.cs
+++ /dev/null
@@ -1,273 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// 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.Runtime.InteropServices.WindowsRuntime;
-using System.Runtime.Serialization.Json;
-using System.Text;
-using System.Threading.Tasks;
-using Windows.Security.Credentials;
-using Windows.Storage;
-using Windows.Storage.Streams;
-using Windows.Web.Http;
-using Windows.Web.Http.Filters;
-using static Microsoft.Tools.WindowsDevicePortal.DevicePortalException;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// Universal Windows Platform implementation of App Deployment methods.
- ///
- public partial class DevicePortal
- {
- ///
- /// API for getting installation status.
- ///
- /// The status
-#pragma warning disable 1998
- public async Task GetInstallStatusAsync()
- {
- ApplicationInstallStatus status = ApplicationInstallStatus.None;
-
- Uri uri = Utilities.BuildEndpoint(
- this.deviceConnection.Connection,
- InstallStateApi);
-
- HttpBaseProtocolFilter httpFilter = new HttpBaseProtocolFilter();
- httpFilter.AllowUI = false;
-
- if (this.deviceConnection.Credentials != null)
- {
- httpFilter.ServerCredential = new PasswordCredential();
- httpFilter.ServerCredential.UserName = this.deviceConnection.Credentials.UserName;
- httpFilter.ServerCredential.Password = this.deviceConnection.Credentials.Password;
- }
-
- using (HttpClient client = new HttpClient(httpFilter))
- {
- this.ApplyHttpHeaders(client, HttpMethods.Get);
-
- using (HttpResponseMessage response = await client.GetAsync(uri))
- {
- if (response.IsSuccessStatusCode)
- {
- if (response.StatusCode == HttpStatusCode.Ok)
- {
- // Status code: 200
- if (response.Content != null)
- {
- Stream dataStream = null;
-
- IBuffer dataBuffer = null;
- using (IHttpContent messageContent = response.Content)
- {
- dataBuffer = await messageContent.ReadAsBufferAsync();
-
- if (dataBuffer != null)
- {
- dataStream = dataBuffer.AsStream();
- }
- }
-
- if (dataStream != null)
- {
- HttpErrorResponse errorResponse = DevicePortal.ReadJsonStream(dataStream);
-
- if (errorResponse.Success)
- {
- status = ApplicationInstallStatus.Completed;
- }
- else
- {
- throw new DevicePortalException(response.StatusCode, errorResponse, uri);
- }
- }
- else
- {
- throw new DevicePortalException(HttpStatusCode.Conflict, "Failed to deserialize GetInstallStatus response.");
- }
- }
- }
- else if (response.StatusCode == HttpStatusCode.NoContent)
- {
- // Status code: 204
- status = ApplicationInstallStatus.InProgress;
- }
- }
- else
- {
- throw await DevicePortalException.CreateAsync(response);
- }
- }
- }
-
- return status;
- }
-#pragma warning restore 1998
-
- ///
- /// Installs an application
- ///
- /// Friendly name (ex: Hello World) of the application. If this parameter is not provided, the name of the package is assumed to be the app name.
- /// The application package file.
- /// List containing the required dependency files.
- /// Optional certificate file.
- /// How frequently we should check the installation state.
- /// Operation timeout.
- /// Indicate whether or not the previous app version should be uninstalled prior to installing.
- /// InstallApplication sends ApplicationInstallStatus events to indicate the current progress in the installation process.
- /// Some applications may opt to not register for the AppInstallStatus event and await on InstallApplication.
- /// Task for tracking completion of install initialization.
- public async Task InstallApplicationAsync(
- string appName,
- StorageFile packageFile,
- List dependencyFiles,
- StorageFile certificateFile = null,
- short stateCheckIntervalMs = 500,
- short timeoutInMinutes = 15,
- bool uninstallPreviousVersion = true)
- {
- string installPhaseDescription = string.Empty;
-
- try
- {
- // If appName was not provided, use the package file name
- if (string.IsNullOrWhiteSpace(appName))
- {
- appName = packageFile.DisplayName;
- }
-
- // Uninstall the application's previous version, if one exists.
- if (uninstallPreviousVersion)
- {
- installPhaseDescription = string.Format("Uninstalling any previous version of {0}", appName);
- this.SendAppInstallStatus(
- ApplicationInstallStatus.InProgress,
- ApplicationInstallPhase.UninstallingPreviousVersion,
- installPhaseDescription);
- AppPackages installedApps = await this.GetInstalledAppPackagesAsync();
- foreach (PackageInfo package in installedApps.Packages)
- {
- if (package.Name == appName)
- {
- await this.UninstallApplicationAsync(package.FullName);
- break;
- }
- }
- }
-
- // Create the API endpoint and generate a unique boundary string.
- Uri uri;
- string boundaryString;
- this.CreateAppInstallEndpointAndBoundaryString(
- packageFile.Name,
- out uri,
- out boundaryString);
-
- using (MemoryStream dataStream = new MemoryStream())
- {
- byte[] data;
-
- // Copy the application package.
- installPhaseDescription = string.Format("Copying: {0}", packageFile.Name);
- this.SendAppInstallStatus(
- ApplicationInstallStatus.InProgress,
- ApplicationInstallPhase.CopyingFile,
- installPhaseDescription);
- data = Encoding.ASCII.GetBytes(string.Format("--{0}\r\n", boundaryString));
- dataStream.Write(data, 0, data.Length);
- await CopyFileToRequestStream(
- packageFile,
- dataStream);
-
- // Copy dependency files, if any.
- foreach (StorageFile depFile in dependencyFiles)
- {
- installPhaseDescription = string.Format("Copying: {0}", depFile.Name);
- this.SendAppInstallStatus(
- ApplicationInstallStatus.InProgress,
- ApplicationInstallPhase.CopyingFile,
- installPhaseDescription);
- data = Encoding.ASCII.GetBytes(string.Format("\r\n--{0}\r\n", boundaryString));
- dataStream.Write(data, 0, data.Length);
- await CopyFileToRequestStream(
- depFile,
- dataStream);
- }
-
- // Copy the certificate file, if provided.
- if (certificateFile != null)
- {
- installPhaseDescription = string.Format("Copying: {0}", certificateFile.Name);
- this.SendAppInstallStatus(
- ApplicationInstallStatus.InProgress,
- ApplicationInstallPhase.CopyingFile,
- installPhaseDescription);
- data = Encoding.ASCII.GetBytes(string.Format("\r\n--{0}\r\n", boundaryString));
- dataStream.Write(data, 0, data.Length);
- await CopyFileToRequestStream(
- certificateFile,
- dataStream);
- }
-
- // Close the installation request data.
- data = Encoding.ASCII.GetBytes(string.Format("\r\n--{0}--\r\n", boundaryString));
- dataStream.Write(data, 0, data.Length);
-
- dataStream.Position = 0;
-
- string contentType = string.Format("multipart/form-data; boundary={0}", boundaryString);
-
- // Make the HTTP request.
- await this.PostAsync(uri, dataStream, contentType);
- }
-
- // Poll the status until complete.
- ApplicationInstallStatus status = ApplicationInstallStatus.InProgress;
- do
- {
- installPhaseDescription = string.Format("Installing {0}", appName);
- this.SendAppInstallStatus(
- ApplicationInstallStatus.InProgress,
- ApplicationInstallPhase.Installing,
- installPhaseDescription);
-
- await Task.Delay(TimeSpan.FromMilliseconds(stateCheckIntervalMs));
-
- status = await this.GetInstallStatusAsync().ConfigureAwait(false);
- }
- while (status == ApplicationInstallStatus.InProgress);
-
- installPhaseDescription = string.Format("{0} installed successfully", appName);
- this.SendAppInstallStatus(
- ApplicationInstallStatus.Completed,
- ApplicationInstallPhase.Idle,
- installPhaseDescription);
- }
- catch (Exception e)
- {
- DevicePortalException dpe = e as DevicePortalException;
-
- if (dpe != null)
- {
- this.SendAppInstallStatus(
- ApplicationInstallStatus.Failed,
- ApplicationInstallPhase.Idle,
- string.Format("Failed to install {0}: {1}", appName, dpe.Reason));
- }
- else
- {
- this.SendAppInstallStatus(
- ApplicationInstallStatus.Failed,
- ApplicationInstallPhase.Idle,
- string.Format("Failed to install {0}: {1}", appName, installPhaseDescription));
- }
- }
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/DefaultDevicePortalConnection.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/DefaultDevicePortalConnection.cs
deleted file mode 100644
index 4b23d4a5..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/DefaultDevicePortalConnection.cs
+++ /dev/null
@@ -1,149 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.Net;
-using static Microsoft.Tools.WindowsDevicePortal.DevicePortal;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// Default implementation of the IDevicePortalConnection interface.
- /// This implementation is designed to be compatibile with all device families.
- ///
- public class DefaultDevicePortalConnection : IDevicePortalConnection
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The fully qualified (ex: "https:/1.2.3.4:4321") address of the device.
- /// The user name used in the connection credentials.
- /// The password used in the connection credentials.
- public DefaultDevicePortalConnection(
- string address,
- string userName,
- string password)
- {
- this.Connection = new Uri(address);
- // append auto- to the credentials to bypass CSRF token requirement on non-Get requests.
- this.Credentials = new NetworkCredential(string.Format("auto-{0}", userName), password);
- }
-
- ///
- /// Gets the URI used to connect to the device.
- ///
- public Uri Connection
- {
- get;
- private set;
- }
-
- ///
- /// Gets Web Socket Connection property
- ///
- public Uri WebSocketConnection
- {
- get
- {
- if (this.Connection == null)
- {
- return null;
- }
-
- // Convert the scheme from http[s] to ws[s].
- string scheme = this.Connection.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase) ? "wss" : "ws";
-
- return new Uri(string.Format("{0}://{1}", scheme, this.Connection.Authority));
- }
- }
-
- ///
- /// Gets the credentials used to connect to the device.
- ///
- public NetworkCredential Credentials
- {
- get;
- private set;
- }
-
- ///
- /// Gets or sets the device's operating system family.
- ///
- public string Family
- {
- get;
- set;
- }
-
- ///
- /// Gets or sets the operating system information.
- ///
- public OperatingSystemInformation OsInfo
- {
- get;
- set;
- }
-
- ///
- /// Updates the device's connection Uri.
- ///
- /// Indicates whether or not to always require a secure connection.
- public void UpdateConnection(bool requiresHttps)
- {
- this.Connection = new Uri(
- string.Format(
- "{0}://{1}",
- requiresHttps ? "https" : "http",
- this.Connection.Authority));
- }
-
- ///
- /// Updates the device's connection Uri.
- ///
- /// Object that describes the current network configuration.
- /// True if an https connection is required, false otherwise.
- /// True if the previous connection's port is to continue to be used, false otherwise.
- public void UpdateConnection(
- IpConfiguration ipConfig,
- bool requiresHttps,
- bool preservePort)
- {
- Uri newConnection = null;
-
- foreach (NetworkAdapterInfo adapter in ipConfig.Adapters)
- {
- foreach (IpAddressInfo addressInfo in adapter.IpAddresses)
- {
- // We take the first, non-169.x.x.x address we find that is not 0.0.0.0.
- if ((addressInfo.Address != "0.0.0.0") && !addressInfo.Address.StartsWith("169."))
- {
- string address = addressInfo.Address;
- if (preservePort)
- {
- address = string.Format(
- "{0}:{1}",
- address,
- this.Connection.Port);
- }
-
- newConnection = new Uri(
- string.Format(
- "{0}://{1}",
- requiresHttps ? "https" : "http",
- address));
- break;
- }
- }
-
- if (newConnection != null)
- {
- this.Connection = newConnection;
- break;
- }
- }
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/DevicePortalWrapperUniversal.snk b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/DevicePortalWrapperUniversal.snk
deleted file mode 100644
index 7ebbdab2..00000000
Binary files a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/DevicePortalWrapperUniversal.snk and /dev/null differ
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/HttpMultipartFileContent.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/HttpMultipartFileContent.cs
deleted file mode 100644
index 4979d40b..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/HttpMultipartFileContent.cs
+++ /dev/null
@@ -1,214 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// 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.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Windows.Foundation;
-using Windows.Storage.Streams;
-using Windows.Web.Http;
-using Windows.Web.Http.Headers;
-
-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 : IHttpContent
- {
- ///
- /// 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;
- this.Headers.ContentType = new HttpMediaTypeHeaderValue(string.Format("multipart/form-data; boundary={0}", this.boundaryString));
- }
-
- ///
- /// Gets the Http Headers
- ///
- public HttpContentHeaderCollection Headers { get; } = new HttpContentHeaderCollection();
-
- ///
- /// 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);
- }
- }
-
- ///
- /// This method is unimplemented.
- ///
- /// Throws an exception
- IAsyncOperationWithProgress IHttpContent.BufferAllAsync()
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Dispose method for cleanup
- ///
- void IDisposable.Dispose()
- {
- this.items.Clear();
- }
-
- ///
- /// This method is unimplemented.
- ///
- /// Throws an exception
- IAsyncOperationWithProgress IHttpContent.ReadAsBufferAsync()
- {
- throw new NotImplementedException();
- }
-
- ///
- /// This method is unimplemented.
- ///
- /// Throws an exception
- IAsyncOperationWithProgress IHttpContent.ReadAsInputStreamAsync()
- {
- throw new NotImplementedException();
- }
-
- ///
- /// This method is unimplemented.
- ///
- /// Throws an exception
- IAsyncOperationWithProgress IHttpContent.ReadAsStringAsync()
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Computes required length for the transfer.
- ///
- /// The computed length value
- /// Whether or not the length was successfully computed
- bool IHttpContent.TryComputeLength(out ulong 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 += (ulong)(boundaryLength + headerdata.Length + new FileInfo(item).Length + 2);
- }
-
- length += (ulong)(boundaryLength + 2);
- return true;
- }
-
- ///
- /// Serializes the stream.
- ///
- /// Serialized Stream
- /// Task tracking progress
- IAsyncOperationWithProgress IHttpContent.WriteToStreamAsync(IOutputStream outputStream)
- {
- return System.Runtime.InteropServices.WindowsRuntime.AsyncInfo.Run((token, progress) =>
- {
- return WriteToStreamAsyncTask(outputStream, (ulong p) => progress.Report(p));
- });
- }
-
- ///
- /// 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));
- }
-
- ///
- /// Serializes the stream.
- ///
- /// Serialized Stream
- /// Progress tracking
- /// Task tracking progress
- private async Task WriteToStreamAsyncTask(IOutputStream outputStream, Action progress)
- {
- ulong bytesWritten = 0;
- var outStream = outputStream.AsStreamForWrite();
- 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);
- bytesWritten += (ulong)boundary.Length;
- var headerdata = GetFileHeader(new FileInfo(item));
- outStream.Write(headerdata, 0, headerdata.Length);
- bytesWritten += (ulong)headerdata.Length;
- using (var file = File.OpenRead(item))
- {
- await file.CopyToAsync(outStream);
- bytesWritten += (ulong)file.Position;
- }
-
- outStream.Write(newline, 0, newline.Length);
- bytesWritten += (ulong)newline.Length;
- await outStream.FlushAsync();
- progress(bytesWritten);
- }
-
- // Close the installation request data.
- boundary = Encoding.ASCII.GetBytes($"--{boundaryString}--\r\n");
- outStream.Write(boundary, 0, boundary.Length);
- await outStream.FlushAsync();
- bytesWritten += (ulong)boundary.Length;
- return bytesWritten;
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RequestHelpers.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RequestHelpers.cs
deleted file mode 100644
index 4b714f95..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RequestHelpers.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.IO;
-using System.Text;
-using System.Threading.Tasks;
-using Windows.Storage;
-using Windows.Storage.Streams;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// Methods for working with Http requests.
- ///
- public partial class DevicePortal
- {
- ///
- /// Copies a file to the specified stream and prepends the necessary content information
- /// required to be part of a multipart form data request.
- ///
- /// The file to be copied.
- /// The stream to which the file will be copied.
- /// The async task.
- private static async Task CopyFileToRequestStream(
- StorageFile file,
- Stream stream)
- {
- byte[] data;
- string fn = file.Name;
- string contentDisposition = string.Format(
- "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n",
- fn,
- fn);
- string contentType = "Content-Type: application/octet-stream\r\n\r\n";
-
- data = Encoding.ASCII.GetBytes(contentDisposition);
- stream.Write(data, 0, data.Length);
-
- data = Encoding.ASCII.GetBytes(contentType);
- stream.Write(data, 0, data.Length);
-
- using (IRandomAccessStreamWithContentType ras = await file.OpenReadAsync())
- {
- Stream fs = ras.AsStreamForRead();
- fs.CopyTo(stream);
- }
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RestDelete.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RestDelete.cs
deleted file mode 100644
index 3d098c7e..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RestDelete.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.IO;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices.WindowsRuntime;
-using System.Threading.Tasks;
-using Windows.Foundation;
-using Windows.Security.Credentials;
-using Windows.Storage.Streams;
-using Windows.Web.Http;
-using Windows.Web.Http.Filters;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// Universal Windows Platform implementation of HTTP DeleteAsync
- ///
- public partial class DevicePortal
- {
- ///
- /// Submits the http delete request to the specified uri.
- ///
- /// The uri to which the delete request will be issued.
- /// Task tracking HTTP completion
-#pragma warning disable 1998
- public async Task DeleteAsync(Uri uri)
- {
- IBuffer dataBuffer = null;
-
- HttpBaseProtocolFilter httpFilter = new HttpBaseProtocolFilter();
- httpFilter.AllowUI = false;
-
- if (this.deviceConnection.Credentials != null)
- {
- httpFilter.ServerCredential = new PasswordCredential();
- httpFilter.ServerCredential.UserName = this.deviceConnection.Credentials.UserName;
- httpFilter.ServerCredential.Password = this.deviceConnection.Credentials.Password;
- }
-
- using (HttpClient client = new HttpClient(httpFilter))
- {
- this.ApplyHttpHeaders(client, HttpMethods.Delete);
- using (HttpResponseMessage response = await client.DeleteAsync(uri))
- {
- if (!response.IsSuccessStatusCode)
- {
- throw await DevicePortalException.CreateAsync(response);
- }
-
- this.RetrieveCsrfToken(response);
-
- if (response.Content != null)
- {
- using (IHttpContent messageContent = response.Content)
- {
- dataBuffer = await messageContent.ReadAsBufferAsync();
- }
- }
- }
- }
-
- return (dataBuffer != null) ? dataBuffer.AsStream() : null;
- }
-#pragma warning restore 1998
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RestGet.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RestGet.cs
deleted file mode 100644
index 353eaa57..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RestGet.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.IO;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices.WindowsRuntime;
-using System.Threading.Tasks;
-using Windows.Foundation;
-using Windows.Security.Credentials;
-using Windows.Storage.Streams;
-using Windows.Web.Http;
-using Windows.Web.Http.Filters;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// Universal Windows Platform implementation of HTTP GetAsync
- ///
- public partial class DevicePortal
- {
- ///
- /// Submits the http get request to the specified uri.
- ///
- /// The uri to which the get request will be issued.
- /// Response data as a stream.
-#pragma warning disable 1998
- public async Task GetAsync(Uri uri)
- {
- IBuffer dataBuffer = null;
-
- HttpBaseProtocolFilter requestSettings = new HttpBaseProtocolFilter();
- requestSettings.AllowUI = false;
-
- if (this.deviceConnection.Credentials != null)
- {
- requestSettings.ServerCredential = new PasswordCredential();
- requestSettings.ServerCredential.UserName = this.deviceConnection.Credentials.UserName;
- requestSettings.ServerCredential.Password = this.deviceConnection.Credentials.Password;
- }
-
- using (HttpClient client = new HttpClient(requestSettings))
- {
- this.ApplyHttpHeaders(client, HttpMethods.Get);
- using (HttpResponseMessage response = await client.GetAsync(uri))
- {
- if (!response.IsSuccessStatusCode)
- {
- throw await DevicePortalException.CreateAsync(response);
- }
-
- this.RetrieveCsrfToken(response);
-
- using (IHttpContent messageContent = response.Content)
- {
- dataBuffer = await messageContent.ReadAsBufferAsync();
- }
- }
- }
-
- return (dataBuffer != null) ? dataBuffer.AsStream() : null;
- }
-#pragma warning restore 1998
- }
-}
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RestPost.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RestPost.cs
deleted file mode 100644
index a34c918f..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RestPost.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.IO;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices.WindowsRuntime;
-using System.Threading.Tasks;
-using Windows.Foundation;
-using Windows.Security.Credentials;
-using Windows.Storage.Streams;
-using Windows.Web.Http;
-using Windows.Web.Http.Filters;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// Universal Windows Platform implementation of HTTP PostAsync
- ///
- public partial class DevicePortal
- {
- ///
- /// Submits the http post request to the specified uri.
- ///
- /// The uri to which the post request will be issued.
- /// Optional stream containing data for the request body.
- /// The type of that request body data.
- /// Task tracking the completion of the POST request
-#pragma warning disable 1998
- public async Task PostAsync(
- Uri uri,
- Stream requestStream = null,
- string requestStreamContentType = null)
- {
- HttpStreamContent requestContent = null;
-
- if (requestStream != null)
- {
- requestContent = new HttpStreamContent(requestStream.AsInputStream());
- requestContent.Headers.Remove(ContentTypeHeaderName);
- requestContent.Headers.TryAppendWithoutValidation(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 for the request body.
- /// Task tracking the completion of the POST request
- public async Task PostAsync(
- Uri uri,
- IHttpContent requestContent)
- {
- IBuffer dataBuffer = null;
- HttpBaseProtocolFilter httpFilter = new HttpBaseProtocolFilter();
- httpFilter.AllowUI = false;
-
- if (this.deviceConnection.Credentials != null)
- {
- httpFilter.ServerCredential = new PasswordCredential();
- httpFilter.ServerCredential.UserName = this.deviceConnection.Credentials.UserName;
- httpFilter.ServerCredential.Password = this.deviceConnection.Credentials.Password;
- }
-
- using (HttpClient client = new HttpClient(httpFilter))
- {
- this.ApplyHttpHeaders(client, HttpMethods.Post);
- using (HttpResponseMessage response = await client.PostAsync(uri, requestContent))
- {
- if (!response.IsSuccessStatusCode)
- {
- throw await DevicePortalException.CreateAsync(response);
- }
-
- this.RetrieveCsrfToken(response);
-
- if (response.Content != null)
- {
- using (IHttpContent messageContent = response.Content)
- {
- dataBuffer = await messageContent.ReadAsBufferAsync();
- }
- }
- }
- }
-
- return (dataBuffer != null) ? dataBuffer.AsStream() : null;
- }
-#pragma warning restore 1998
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RestPut.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RestPut.cs
deleted file mode 100644
index 486f3af3..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/RestPut.cs
+++ /dev/null
@@ -1,76 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.IO;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices.WindowsRuntime;
-using System.Threading.Tasks;
-using Windows.Foundation;
-using Windows.Security.Credentials;
-using Windows.Storage.Streams;
-using Windows.Web.Http;
-using Windows.Web.Http.Filters;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// Universal Windows Platform implementation of HTTP PutAsync
- ///
- public partial class DevicePortal
- {
- ///
- /// Submits the http put request to the specified uri.
- ///
- /// The uri to which the put request will be issued.
- /// The HTTP content comprising the body of the request.
- /// Task tracking the PUT completion.
-#pragma warning disable 1998
- public async Task PutAsync(
- Uri uri,
- IHttpContent body = null)
- {
- IBuffer dataBuffer = null;
-
- HttpBaseProtocolFilter httpFilter = new HttpBaseProtocolFilter();
- httpFilter.AllowUI = false;
-
- if (this.deviceConnection.Credentials != null)
- {
- httpFilter.ServerCredential = new PasswordCredential();
- httpFilter.ServerCredential.UserName = this.deviceConnection.Credentials.UserName;
- httpFilter.ServerCredential.Password = this.deviceConnection.Credentials.Password;
- }
-
- using (HttpClient client = new HttpClient(httpFilter))
- {
- this.ApplyHttpHeaders(client, HttpMethods.Put);
-
- // Send the request
- using (HttpResponseMessage response = await client.PutAsync(uri, null))
- {
- if (!response.IsSuccessStatusCode)
- {
- throw await DevicePortalException.CreateAsync(response);
- }
-
- this.RetrieveCsrfToken(response);
-
- if (response.Content != null)
- {
- using (IHttpContent messageContent = response.Content)
- {
- dataBuffer = await messageContent.ReadAsBufferAsync();
- }
- }
- }
- }
-
- return (dataBuffer != null) ? dataBuffer.AsStream() : null;
- }
-#pragma warning restore 1998
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/WebSocket.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/WebSocket.cs
deleted file mode 100644
index e3fe6618..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/HttpRest/WebSocket.cs
+++ /dev/null
@@ -1,175 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System;
-using System.IO;
-using System.Threading.Tasks;
-using Windows.Networking.Sockets;
-using Windows.Security.Credentials;
-using Windows.Storage.Streams;
-
-namespace Microsoft.Tools.WindowsDevicePortal
-{
- ///
- /// HTTP Websocket Wrapper
- ///
- /// Return type for the websocket messages.
- internal partial class WebSocket
- {
- ///
- /// The websocket connection has closed after the request was fulfilled.
- ///
- private const ushort WebSocketCloseStatusNormalClosure = 1000;
-
- ///
- /// The that is being wrapped.
- ///
- private MessageWebSocket websocket = null;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// Implementation of a connection object.
- /// specifies whether the web socket should send streams (useful for creating mock data).
- public WebSocket(IDevicePortalConnection connection, bool sendStreams = false)
- {
- this.sendStreams = sendStreams;
- this.deviceConnection = connection;
- this.IsListeningForMessages = false;
- }
-
- ///
- /// Opens a connection to the specified websocket API.
- ///
- /// The uri that the weboscket should connect to
- /// The task of opening a connection to the websocket.
- private async Task ConnectInternalAsync(
- Uri endpoint)
- {
- this.websocket = new MessageWebSocket();
-
- this.websocket.Control.MessageType = SocketMessageType.Utf8;
-
- this.websocket.MessageReceived += this.MessageReceived;
-
- this.websocket.Closed += (senderSocket, args) =>
- {
- if (this.websocket != null)
- {
- this.websocket.Dispose();
- this.websocket = null;
- this.IsListeningForMessages = false;
- }
- };
-
- if (this.deviceConnection.Credentials != null)
- {
- PasswordCredential cred = new PasswordCredential();
- cred.UserName = this.deviceConnection.Credentials.UserName;
- cred.Password = this.deviceConnection.Credentials.Password;
-
- this.websocket.Control.ServerCredential = cred;
- }
-
- //Origin address must be especially cooked to pass through all Device Portal checks
- string OriginAddress = this.deviceConnection.Connection.Scheme + "://" + this.deviceConnection.Connection.Host;
- if ((this.deviceConnection.Connection.Scheme == "http" && this.deviceConnection.Connection.Port != 80) ||
- (this.deviceConnection.Connection.Scheme == "https" && this.deviceConnection.Connection.Port != 443))
- {
- OriginAddress += ":" + this.deviceConnection.Connection.Port;
- }
- this.websocket.SetRequestHeader("Origin", OriginAddress);
-
- await this.websocket.ConnectAsync(endpoint);
-
- this.IsConnected = true;
- }
-
- ///
- /// Closes the connection to the websocket.
- ///
- /// The task of closing the websocket connection.
- private async Task CloseInternalAsync()
- {
- await Task.Run(() =>
- {
- this.websocket.Close(WebSocketCloseStatusNormalClosure, "Closed due to user request.");
- this.websocket.Dispose();
- this.websocket = null;
- this.IsConnected = false;
- });
- }
-
- ///
- /// Opens a connection to the specified websocket API and starts listening for messages.
- ///
- /// The task of opening a connection to the websocket.
- private async Task StartListeningForMessagesInternalAsync()
- {
- await Task.Run(() =>
- {
- this.IsListeningForMessages = true;
- });
- }
-
- ///
- /// Converts received stream to a parsed message and passes it to the WebSocketMessageReceived handler.
- ///
- /// The that sent the message.
- /// The message from the web socket.
- private async void MessageReceived(MessageWebSocket sender, MessageWebSocketMessageReceivedEventArgs args)
- {
- if (this.IsListeningForMessages)
- {
- using (IInputStream inputStream = args.GetDataStream())
- {
- Stream stream = new MemoryStream();
-
- await inputStream.AsStreamForRead().CopyToAsync(stream);
-
- // Ensure we return with the stream pointed at the origin.
- stream.Position = 0;
-
- this.ConvertStreamToMessage(stream);
- }
- }
- }
-
- ///
- /// Stops listening for messages from the websocket.
- ///
- /// The task of closing the websocket connection.
- private async Task StopListeningForMessagesInternalAsync()
- {
- await Task.Run(() =>
- {
- this.IsListeningForMessages = false;
- });
- }
-
- ///
- /// Sends a message to the websocket.
- ///
- /// The message to be sent.
- /// The task of sending the specified message to the server.
- private async Task SendMessageInternalAsync(string message)
- {
- using (DataWriter data = new DataWriter(this.websocket.OutputStream))
- {
- // Load the content into the data writer.
- data.UnicodeEncoding = UnicodeEncoding.Utf8;
- data.WriteString(message);
-
- // Send the content to the output stream.
- await data.StoreAsync();
- await data.FlushAsync();
-
- // Do not close the output stream when the data writer is disposed.
- data.DetachStream();
- }
- }
- }
-}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/Properties/AssemblyInfo.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/Properties/AssemblyInfo.cs
deleted file mode 100644
index 8c8340f4..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-//----------------------------------------------------------------------------------------------
-//
-// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
-//
-//----------------------------------------------------------------------------------------------
-
-using System.Reflection;
-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("WindowsDevicePortalWrapper.UniversalWindows")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("WindowsDevicePortalWrapper.UniversalWindows")]
-[assembly: AssemblyCopyright("Copyright © 2016-2017")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.9.5.1")]
-[assembly: AssemblyFileVersion("0.9.5.1")]
-[assembly: ComVisible(false)]
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/Properties/WindowsDevicePortalWrapper.UniversalWindows.rd.xml b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/Properties/WindowsDevicePortalWrapper.UniversalWindows.rd.xml
deleted file mode 100644
index fbec0154..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/Properties/WindowsDevicePortalWrapper.UniversalWindows.rd.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/Settings.StyleCop b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/Settings.StyleCop
deleted file mode 100644
index bf8d5cc2..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/Settings.StyleCop
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/WindowsDevicePortalWrapper.UniversalWindows.csproj b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/WindowsDevicePortalWrapper.UniversalWindows.csproj
deleted file mode 100644
index 3d8f3cb3..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/WindowsDevicePortalWrapper.UniversalWindows.csproj
+++ /dev/null
@@ -1,149 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}
- Library
- Properties
- Microsoft.Tools.WindowsDevicePortal
- WindowsDevicePortalWrapper.UniversalWindows
- en-US
- UAP
- 10.0.14393.0
- 10.0.10240.0
- 14
- 512
- {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- True
- $(registry:HKEY_LOCAL_MACHINE\Software\CodePlex\StyleCop@TargetsDir)
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
- prompt
- 4
- bin\Release\WindowsDevicePortalWrapper.UniversalWindows.XML
-
-
- x86
- true
- bin\x86\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
- ;2008
- full
- x86
- false
- prompt
-
-
- x86
- bin\x86\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
- true
- ;2008
- pdbonly
- x86
- false
- prompt
-
-
- ARM
- true
- bin\ARM\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
- ;2008
- full
- ARM
- false
- prompt
-
-
- ARM
- bin\ARM\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
- true
- ;2008
- pdbonly
- ARM
- false
- prompt
-
-
- x64
- true
- bin\x64\Debug\
- DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
- ;2008
- full
- x64
- false
- prompt
-
-
- x64
- bin\x64\Release\
- TRACE;NETFX_CORE;WINDOWS_UWP
- true
- ;2008
- pdbonly
- x64
- false
- prompt
-
-
- true
-
-
- false
-
-
- DevicePortalWrapperUniversal.snk
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 14.0
-
-
-
-
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/project.json b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/project.json
deleted file mode 100644
index 73665b13..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.UniversalWindows/project.json
+++ /dev/null
@@ -1,16 +0,0 @@
-{
- "dependencies": {
- "Microsoft.NETCore.UniversalWindowsPlatform": "5.1.0",
- },
- "frameworks": {
- "uap10.0": {}
- },
- "runtimes": {
- "win10-arm": {},
- "win10-arm-aot": {},
- "win10-x86": {},
- "win10-x86-aot": {},
- "win10-x64": {},
- "win10-x64-aot": {}
- }
-}
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.sln b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.sln
index e1e9ea56..b1ec730e 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.sln
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.sln
@@ -1,17 +1,13 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26403.0
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29521.150
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsDevicePortalWrapper", "WindowsDevicePortalWrapper\WindowsDevicePortalWrapper.csproj", "{6A9E862E-5CDA-4A8A-BBC0-56E9EA921E39}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindowsDevicePortalWrapper", "WindowsDevicePortalWrapper\WindowsDevicePortalWrapper.csproj", "{6A9E862E-5CDA-4A8A-BBC0-56E9EA921E39}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsDevicePortalWrapper.UniversalWindows", "WindowsDevicePortalWrapper.UniversalWindows\WindowsDevicePortalWrapper.UniversalWindows.csproj", "{F2D8B145-A737-494E-AEF4-508F9D02E0D7}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTestProject", "UnitTestProject\UnitTestProject.csproj", "{4FC7C762-ADBE-4A0A-882D-10771CD8BD55}"
EndProject
-Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "WindowsDevicePortalWrapper.Shared", "WindowsDevicePortalWrapper.Shared\WindowsDevicePortalWrapper.Shared.shproj", "{AF72A46D-5D30-4FB4-8D3E-B516ED19F9A4}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject", "UnitTestProject\UnitTestProject.csproj", "{4FC7C762-ADBE-4A0A-882D-10771CD8BD55}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MockDataGenerator", "MockDataGenerator\MockDataGenerator.csproj", "{C5AF45CA-C804-42ED-81FD-041B9B7FDBBD}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MockDataGenerator", "MockDataGenerator\MockDataGenerator.csproj", "{C5AF45CA-C804-42ED-81FD-041B9B7FDBBD}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{07E3DB19-3DDB-42EF-BDAB-0A61F07D637C}"
EndProject
@@ -19,11 +15,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{84BC236A
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{20AF4B15-122A-4C9B-A941-73824C518AFD}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleWdpClient.UniversalWindows", "..\Samples\SampleWdpClient.UniversalWindows\SampleWdpClient.UniversalWindows.csproj", "{E605CD33-1B19-4091-9BD2-289D3CA4729E}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XboxWdpDriver", "..\Samples\XboxWdpDriver\XboxWdpDriver.csproj", "{1F3CA46B-1E52-418E-A293-23F3FA3BD213}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XboxWdpDriver", "..\Samples\XboxWdpDriver\XboxWdpDriver.csproj", "{1F3CA46B-1E52-418E-A293-23F3FA3BD213}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleWdpClient", "..\Samples\SampleWdpClient\SampleWdpClient.csproj", "{7E0481EB-514A-4292-AD1D-3A3EAF38D359}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SampleWdpClient", "..\Samples\SampleWdpClient\SampleWdpClient.csproj", "{7E0481EB-514A-4292-AD1D-3A3EAF38D359}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{0A85BE2B-52BE-4ACD-A332-991B3B81ED49}"
ProjectSection(SolutionItems) = preProject
@@ -32,12 +26,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{
EndProjectSection
EndProject
Global
- GlobalSection(SharedMSBuildProjectFiles) = preSolution
- WindowsDevicePortalWrapper.Shared\WindowsDevicePortalWrapper.Shared.projitems*{4fc7c762-adbe-4a0a-882d-10771cd8bd55}*SharedItemsImports = 4
- WindowsDevicePortalWrapper.Shared\WindowsDevicePortalWrapper.Shared.projitems*{6a9e862e-5cda-4a8a-bbc0-56e9ea921e39}*SharedItemsImports = 4
- WindowsDevicePortalWrapper.Shared\WindowsDevicePortalWrapper.Shared.projitems*{af72a46d-5d30-4fb4-8d3e-b516ed19f9a4}*SharedItemsImports = 13
- WindowsDevicePortalWrapper.Shared\WindowsDevicePortalWrapper.Shared.projitems*{f2d8b145-a737-494e-aef4-508f9d02e0d7}*SharedItemsImports = 4
- EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
@@ -65,22 +53,6 @@ Global
{6A9E862E-5CDA-4A8A-BBC0-56E9EA921E39}.Release|x64.Build.0 = Release|Any CPU
{6A9E862E-5CDA-4A8A-BBC0-56E9EA921E39}.Release|x86.ActiveCfg = Release|Any CPU
{6A9E862E-5CDA-4A8A-BBC0-56E9EA921E39}.Release|x86.Build.0 = Release|Any CPU
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Debug|ARM.ActiveCfg = Debug|ARM
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Debug|ARM.Build.0 = Debug|ARM
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Debug|x64.ActiveCfg = Debug|x64
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Debug|x64.Build.0 = Debug|x64
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Debug|x86.ActiveCfg = Debug|x86
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Debug|x86.Build.0 = Debug|x86
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Release|Any CPU.Build.0 = Release|Any CPU
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Release|ARM.ActiveCfg = Release|ARM
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Release|ARM.Build.0 = Release|ARM
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Release|x64.ActiveCfg = Release|x64
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Release|x64.Build.0 = Release|x64
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Release|x86.ActiveCfg = Release|x86
- {F2D8B145-A737-494E-AEF4-508F9D02E0D7}.Release|x86.Build.0 = Release|x86
{4FC7C762-ADBE-4A0A-882D-10771CD8BD55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4FC7C762-ADBE-4A0A-882D-10771CD8BD55}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4FC7C762-ADBE-4A0A-882D-10771CD8BD55}.Debug|ARM.ActiveCfg = Debug|Any CPU
@@ -113,30 +85,6 @@ Global
{C5AF45CA-C804-42ED-81FD-041B9B7FDBBD}.Release|x64.Build.0 = Release|Any CPU
{C5AF45CA-C804-42ED-81FD-041B9B7FDBBD}.Release|x86.ActiveCfg = Release|Any CPU
{C5AF45CA-C804-42ED-81FD-041B9B7FDBBD}.Release|x86.Build.0 = Release|Any CPU
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Debug|Any CPU.ActiveCfg = Debug|x86
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Debug|Any CPU.Build.0 = Debug|x86
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Debug|Any CPU.Deploy.0 = Debug|x86
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Debug|ARM.ActiveCfg = Debug|ARM
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Debug|ARM.Build.0 = Debug|ARM
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Debug|ARM.Deploy.0 = Debug|ARM
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Debug|x64.ActiveCfg = Debug|x64
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Debug|x64.Build.0 = Debug|x64
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Debug|x64.Deploy.0 = Debug|x64
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Debug|x86.ActiveCfg = Debug|x86
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Debug|x86.Build.0 = Debug|x86
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Debug|x86.Deploy.0 = Debug|x86
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Release|Any CPU.ActiveCfg = Release|x86
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Release|Any CPU.Build.0 = Release|x86
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Release|Any CPU.Deploy.0 = Release|x86
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Release|ARM.ActiveCfg = Release|ARM
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Release|ARM.Build.0 = Release|ARM
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Release|ARM.Deploy.0 = Release|ARM
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Release|x64.ActiveCfg = Release|x64
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Release|x64.Build.0 = Release|x64
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Release|x64.Deploy.0 = Release|x64
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Release|x86.ActiveCfg = Release|x86
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Release|x86.Build.0 = Release|x86
- {E605CD33-1B19-4091-9BD2-289D3CA4729E}.Release|x86.Deploy.0 = Release|x86
{1F3CA46B-1E52-418E-A293-23F3FA3BD213}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F3CA46B-1E52-418E-A293-23F3FA3BD213}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F3CA46B-1E52-418E-A293-23F3FA3BD213}.Debug|ARM.ActiveCfg = Debug|Any CPU
@@ -176,8 +124,10 @@ Global
GlobalSection(NestedProjects) = preSolution
{4FC7C762-ADBE-4A0A-882D-10771CD8BD55} = {20AF4B15-122A-4C9B-A941-73824C518AFD}
{C5AF45CA-C804-42ED-81FD-041B9B7FDBBD} = {84BC236A-C79C-47E2-A5A3-F6FF03BE64F3}
- {E605CD33-1B19-4091-9BD2-289D3CA4729E} = {07E3DB19-3DDB-42EF-BDAB-0A61F07D637C}
{1F3CA46B-1E52-418E-A293-23F3FA3BD213} = {07E3DB19-3DDB-42EF-BDAB-0A61F07D637C}
{7E0481EB-514A-4292-AD1D-3A3EAF38D359} = {07E3DB19-3DDB-42EF-BDAB-0A61F07D637C}
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {936C9913-9A2F-4E36-BD3E-658B41786D5D}
+ EndGlobalSection
EndGlobal
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppCrashDumpCollection.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/AppCrashDumpCollection.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppCrashDumpCollection.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/AppCrashDumpCollection.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/AppDeployment.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/AppDeployment.cs
index c410b35a..cc11e18f 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/AppDeployment.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/AppDeployment.cs
@@ -10,15 +10,393 @@
using System.Net.Http;
using System.Runtime.Serialization.Json;
using System.Threading.Tasks;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
using static Microsoft.Tools.WindowsDevicePortal.DevicePortalException;
namespace Microsoft.Tools.WindowsDevicePortal
{
///
- /// .net 4.x implementation of App Deployment methods.
+ /// Wrappers for App Deployment methods.
///
public partial class DevicePortal
{
+ ///
+ /// API to retrieve list of installed packages.
+ ///
+ public static readonly string InstalledPackagesApi = "api/app/packagemanager/packages";
+
+ ///
+ /// Install state API.
+ ///
+ public static readonly string InstallStateApi = "api/app/packagemanager/state";
+
+ ///
+ /// API for package management.
+ ///
+ public static readonly string PackageManagerApi = "api/app/packagemanager/package";
+
+ ///
+ /// App Install Status handler.
+ ///
+ public event ApplicationInstallStatusEventHandler AppInstallStatus;
+
+ ///
+ /// Gets the collection of applications installed on the device.
+ ///
+ /// AppPackages object containing the list of installed application packages.
+ public async Task GetInstalledAppPackagesAsync()
+ {
+ return await this.GetAsync(InstalledPackagesApi);
+ }
+
+ ///
+ /// Installs an application
+ ///
+ /// Friendly name (ex: Hello World) of the application. If this parameter is not provided, the name of the package is assumed to be the app name.
+ /// Full name of the application package file.
+ /// List containing the full names of any required dependency files.
+ /// Full name of the optional certificate file.
+ /// How frequently we should check the installation state.
+ /// Operation timeout.
+ /// Indicate whether or not the previous app version should be uninstalled prior to installing.
+ /// InstallApplication sends ApplicationInstallStatus events to indicate the current progress in the installation process.
+ /// Some applications may opt to not register for the AppInstallStatus event and await on InstallApplication.
+ /// Task for tracking completion of install initialization.
+ public async Task InstallApplicationAsync(
+ string appName,
+ string packageFileName,
+ List dependencyFileNames,
+ string certificateFileName = null,
+ short stateCheckIntervalMs = 500,
+ short timeoutInMinutes = 15,
+ bool uninstallPreviousVersion = true)
+ {
+ string installPhaseDescription = string.Empty;
+
+ try
+ {
+ FileInfo packageFile = new FileInfo(packageFileName);
+
+ // If appName was not provided, use the package file name
+ if (string.IsNullOrEmpty(appName))
+ {
+ appName = packageFile.Name;
+ }
+
+ // Uninstall the application's previous version, if one exists.
+ if (uninstallPreviousVersion)
+ {
+ installPhaseDescription = string.Format("Uninstalling any previous version of {0}", appName);
+ this.SendAppInstallStatus(
+ ApplicationInstallStatus.InProgress,
+ ApplicationInstallPhase.UninstallingPreviousVersion,
+ installPhaseDescription);
+ AppPackages installedApps = await this.GetInstalledAppPackagesAsync();
+ foreach (PackageInfo package in installedApps.Packages)
+ {
+ if (package.Name == appName)
+ {
+ await this.UninstallApplicationAsync(package.FullName);
+ break;
+ }
+ }
+ }
+
+ // Create the API endpoint and generate a unique boundary string.
+ Uri uri;
+ string boundaryString;
+ this.CreateAppInstallEndpointAndBoundaryString(
+ packageFile.Name,
+ out uri,
+ out boundaryString);
+
+ installPhaseDescription = string.Format("Copying: {0}", packageFile.Name);
+ this.SendAppInstallStatus(
+ ApplicationInstallStatus.InProgress,
+ ApplicationInstallPhase.CopyingFile,
+ installPhaseDescription);
+
+ var content = new HttpMultipartFileContent();
+ content.Add(packageFile.FullName);
+ content.AddRange(dependencyFileNames);
+ content.Add(certificateFileName);
+ await this.PostAsync(uri, content);
+
+ // Poll the status until complete.
+ ApplicationInstallStatus status = ApplicationInstallStatus.InProgress;
+ do
+ {
+ installPhaseDescription = string.Format("Installing {0}", appName);
+ this.SendAppInstallStatus(
+ ApplicationInstallStatus.InProgress,
+ ApplicationInstallPhase.Installing,
+ installPhaseDescription);
+
+ await Task.Delay(TimeSpan.FromMilliseconds(stateCheckIntervalMs));
+
+ status = await this.GetInstallStatusAsync().ConfigureAwait(false);
+ }
+ while (status == ApplicationInstallStatus.InProgress);
+
+ installPhaseDescription = string.Format("{0} installed successfully", appName);
+ this.SendAppInstallStatus(
+ ApplicationInstallStatus.Completed,
+ ApplicationInstallPhase.Idle,
+ installPhaseDescription);
+ }
+ catch (Exception e)
+ {
+ DevicePortalException dpe = e as DevicePortalException;
+
+ if (dpe != null)
+ {
+ this.SendAppInstallStatus(
+ ApplicationInstallStatus.Failed,
+ ApplicationInstallPhase.Idle,
+ string.Format("Failed to install {0}: {1}", appName, dpe.Reason));
+ }
+ else
+ {
+ this.SendAppInstallStatus(
+ ApplicationInstallStatus.Failed,
+ ApplicationInstallPhase.Idle,
+ string.Format("Failed to install {0}: {1}", appName, installPhaseDescription));
+ }
+ }
+ }
+
+ ///
+ /// Uninstalls the specified application.
+ ///
+ /// The name of the application package to uninstall.
+ /// Task tracking the uninstall operation.
+ public async Task UninstallApplicationAsync(string packageName)
+ {
+ await this.DeleteAsync(
+ PackageManagerApi,
+ //// NOTE: When uninstalling an app package, the package name is not Hex64 encoded.
+ string.Format("package={0}", packageName));
+ }
+
+ ///
+ /// Builds the application installation Uri and generates a unique boundary string for the multipart form data.
+ ///
+ /// The name of the application package.
+ /// The endpoint for the install request.
+ /// Unique string used to separate the parts of the multipart form data.
+ private void CreateAppInstallEndpointAndBoundaryString(
+ string packageName,
+ out Uri uri,
+ out string boundaryString)
+ {
+ uri = Utilities.BuildEndpoint(
+ this.deviceConnection.Connection,
+ PackageManagerApi,
+ string.Format("package={0}", packageName));
+
+ boundaryString = Guid.NewGuid().ToString();
+ }
+
+ ///
+ /// Sends application install status.
+ ///
+ /// Status of the installation.
+ /// Current installation phase (ex: Uninstalling previous version)
+ /// Optional error message describing the install status.
+ private void SendAppInstallStatus(
+ ApplicationInstallStatus status,
+ ApplicationInstallPhase phase,
+ string message = "")
+ {
+ this.AppInstallStatus?.Invoke(
+ this,
+ new ApplicationInstallStatusEventArgs(status, phase, message));
+ }
+
+ #region Data contract
+ ///
+ /// Object representing a list of Application Packages
+ ///
+ [DataContract]
+ public class AppPackages
+ {
+ ///
+ /// Gets a list of the packages
+ ///
+ [DataMember(Name = "InstalledPackages")]
+ public List Packages { get; private set; }
+
+ ///
+ /// Presents a user readable representation of a list of AppPackages
+ ///
+ /// User readable list of AppPackages.
+ public override string ToString()
+ {
+ string output = "Packages:\n";
+ foreach (PackageInfo package in this.Packages)
+ {
+ output += package;
+ }
+
+ return output;
+ }
+ }
+
+ ///
+ /// Object representing the install state
+ ///
+ [DataContract]
+ public class InstallState
+ {
+ ///
+ /// Gets install state code
+ ///
+ [DataMember(Name = "Code")]
+ public int Code { get; private set; }
+
+ ///
+ /// Gets message text
+ ///
+ [DataMember(Name = "CodeText")]
+ public string CodeText { get; private set; }
+
+ ///
+ /// Gets reason for state
+ ///
+ [DataMember(Name = "Reason")]
+ public string Reason { get; private set; }
+
+ ///
+ /// Gets a value indicating whether this was successful
+ ///
+ [DataMember(Name = "Success")]
+ public bool WasSuccessful { get; private set; }
+ }
+
+ ///
+ /// object representing the package information
+ ///
+ [DataContract]
+ public class PackageInfo
+ {
+ ///
+ /// Gets package name
+ ///
+ [DataMember(Name = "Name")]
+ public string Name { get; private set; }
+
+ ///
+ /// Gets package family name
+ ///
+ [DataMember(Name = "PackageFamilyName")]
+ public string FamilyName { get; private set; }
+
+ ///
+ /// Gets package full name
+ ///
+ [DataMember(Name = "PackageFullName")]
+ public string FullName { get; private set; }
+
+ ///
+ /// Gets package relative Id
+ ///
+ [DataMember(Name = "PackageRelativeId")]
+ public string AppId { get; private set; }
+
+ ///
+ /// Gets package publisher
+ ///
+ [DataMember(Name = "Publisher")]
+ public string Publisher { get; private set; }
+
+ ///
+ /// Gets package version
+ ///
+ [DataMember(Name = "Version")]
+ public PackageVersion Version { get; private set; }
+
+ ///
+ /// Gets package origin, a measure of how the app was installed.
+ /// PackageOrigin_Unknown = 0,
+ /// PackageOrigin_Unsigned = 1,
+ /// PackageOrigin_Inbox = 2,
+ /// PackageOrigin_Store = 3,
+ /// PackageOrigin_DeveloperUnsigned = 4,
+ /// PackageOrigin_DeveloperSigned = 5,
+ /// PackageOrigin_LineOfBusiness = 6
+ ///
+ [DataMember(Name = "PackageOrigin")]
+ public int PackageOrigin { get; private set; }
+
+ ///
+ /// Helper method to determine if the app was sideloaded and therefore can be used with e.g. GetFolderContentsAsync
+ ///
+ /// True if the package is sideloaded.
+ public bool IsSideloaded()
+ {
+ return this.PackageOrigin == 4 || this.PackageOrigin == 5;
+ }
+
+ ///
+ /// Get a string representation of the package
+ ///
+ /// String representation
+ public override string ToString()
+ {
+ return string.Format("\t{0}\n\t\t{1}\n", this.FullName, this.AppId);
+ }
+ }
+
+ ///
+ /// Object representing a package version
+ ///
+ [DataContract]
+ public class PackageVersion
+ {
+ ///
+ /// Gets version build
+ ///
+ [DataMember(Name = "Build")]
+ public int Build { get; private set; }
+
+ ///
+ /// Gets package Major number
+ ///
+ [DataMember(Name = "Major")]
+ public int Major { get; private set; }
+
+ ///
+ /// Gets package minor number
+ ///
+ [DataMember(Name = "Minor")]
+ public int Minor { get; private set; }
+
+ ///
+ /// Gets package revision
+ ///
+ [DataMember(Name = "Revision")]
+ public int Revision { get; private set; }
+
+ ///
+ /// Gets package version
+ ///
+ public Version Version
+ {
+ get { return new Version(this.Major, this.Minor, this.Build, this.Revision); }
+ }
+
+ ///
+ /// Get a string representation of a version
+ ///
+ /// String representation
+ public override string ToString()
+ {
+ return Version.ToString();
+ }
+ }
+ #endregion // Data contract
+
///
/// Gets the status of a pending or most recent installation, if any.
///
@@ -31,72 +409,63 @@ public async Task GetInstallStatusAsync()
this.deviceConnection.Connection,
InstallStateApi);
- WebRequestHandler handler = new WebRequestHandler();
- handler.UseDefaultCredentials = false;
- handler.Credentials = this.deviceConnection.Credentials;
- handler.ServerCertificateValidationCallback = this.ServerCertificateValidation;
-
- using (HttpClient client = new HttpClient(handler))
+ using (HttpResponseMessage response = await this.HttpClient.GetAsync(uri).ConfigureAwait(false))
{
- this.ApplyHttpHeaders(client, HttpMethods.Get);
- using (HttpResponseMessage response = await client.GetAsync(uri).ConfigureAwait(false))
+ if (response.IsSuccessStatusCode)
{
- if (response.IsSuccessStatusCode)
+ if (response.StatusCode == HttpStatusCode.OK)
{
- if (response.StatusCode == HttpStatusCode.OK)
+ // Status code: 200
+ if (response.Content == null)
{
- // Status code: 200
- if (response.Content == null)
+ status = ApplicationInstallStatus.Completed;
+ }
+ else
+ {
+ // If we have a response body, it's possible this was an error
+ // (even though we got an HTTP 200).
+ Stream dataStream = null;
+ using (HttpContent content = response.Content)
{
- status = ApplicationInstallStatus.Completed;
+ dataStream = new MemoryStream();
+
+ await content.CopyToAsync(dataStream).ConfigureAwait(false);
+
+ // Ensure we point the stream at the origin.
+ dataStream.Position = 0;
}
- else
- {
- // If we have a response body, it's possible this was an error
- // (even though we got an HTTP 200).
- Stream dataStream = null;
- using (HttpContent content = response.Content)
- {
- dataStream = new MemoryStream();
- await content.CopyToAsync(dataStream).ConfigureAwait(false);
+ if (dataStream != null)
+ {
+ DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(HttpErrorResponse));
- // Ensure we point the stream at the origin.
- dataStream.Position = 0;
- }
+ HttpErrorResponse errorResponse = (HttpErrorResponse)serializer.ReadObject(dataStream);
- if (dataStream != null)
+ if (errorResponse.Success)
{
- DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(HttpErrorResponse));
-
- HttpErrorResponse errorResponse = (HttpErrorResponse)serializer.ReadObject(dataStream);
-
- if (errorResponse.Success)
- {
- status = ApplicationInstallStatus.Completed;
- }
- else
- {
- throw new DevicePortalException(response.StatusCode, errorResponse, uri);
- }
+ status = ApplicationInstallStatus.Completed;
}
else
{
- throw new DevicePortalException(response.StatusCode, "Failed to deserialize GetInstallStatus response.");
+ throw new DevicePortalException(response.StatusCode, errorResponse, uri);
}
}
- }
- else if (response.StatusCode == HttpStatusCode.NoContent)
- {
- // Status code: 204
- status = ApplicationInstallStatus.InProgress;
+ else
+ {
+ throw new DevicePortalException(response.StatusCode, "Failed to deserialize GetInstallStatus response.");
+ }
}
}
- else
+ else if (response.StatusCode == HttpStatusCode.NoContent)
{
- throw await DevicePortalException.CreateAsync(response);
+ // Status code: 204
+ status = ApplicationInstallStatus.InProgress;
}
}
+ else
+ {
+ throw await DevicePortalException.CreateAsync(response);
+ }
}
return status;
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppFileExplorer.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/AppFileExplorer.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/AppFileExplorer.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/AppFileExplorer.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/DeviceManager.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/DeviceManager.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/DeviceManager.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/DeviceManager.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/Dns-Sd.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/Dns-Sd.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/Dns-Sd.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/Dns-Sd.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/DumpCollection.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/DumpCollection.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/DumpCollection.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/DumpCollection.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/Etw.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/Etw.cs
similarity index 97%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/Etw.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/Etw.cs
index eef4e617..aa8943d6 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/Etw.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/Etw.cs
@@ -132,11 +132,7 @@ private async Task InitializeRealtimeEventsWebSocketAsync()
{
if (this.realtimeEventsWebSocket == null)
{
-#if WINDOWS_UWP
- this.realtimeEventsWebSocket = new WebSocket(this.deviceConnection);
-#else
- this.realtimeEventsWebSocket = new WebSocket(this.deviceConnection, this.ServerCertificateValidation);
-#endif
+ this.realtimeEventsWebSocket = this.CreateWebSocket();
}
await this.realtimeEventsWebSocket.ConnectAsync(RealtimeEtwSessionApi);
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/Networking.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/Networking.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/Networking.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/Networking.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/OsInformation.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/OsInformation.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/OsInformation.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/OsInformation.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/PerformanceData.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/PerformanceData.cs
similarity index 97%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/PerformanceData.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/PerformanceData.cs
index 35b519c7..2ac5b79f 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/PerformanceData.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/PerformanceData.cs
@@ -63,12 +63,7 @@ public async Task StartListeningForRunningProcessesAsync()
{
if (this.deviceProcessesWebSocket == null)
{
-#if WINDOWS_UWP
- this.deviceProcessesWebSocket = new WebSocket(this.deviceConnection);
-#else
- this.deviceProcessesWebSocket = new WebSocket(this.deviceConnection, this.ServerCertificateValidation);
-#endif
-
+ this.deviceProcessesWebSocket = this.CreateWebSocket();
this.deviceProcessesWebSocket.WebSocketMessageReceived += this.RunningProcessesReceivedHandler;
}
else
@@ -109,12 +104,7 @@ public async Task StartListeningForSystemPerfAsync()
{
if (this.systemPerfWebSocket == null)
{
-#if WINDOWS_UWP
- this.systemPerfWebSocket = new WebSocket(this.deviceConnection);
-#else
- this.systemPerfWebSocket = new WebSocket(this.deviceConnection, this.ServerCertificateValidation);
-#endif
-
+ this.systemPerfWebSocket = this.CreateWebSocket();
this.systemPerfWebSocket.WebSocketMessageReceived += this.SystemPerfReceivedHandler;
}
else
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/Power.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/Power.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/Power.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/Power.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/RemoteControl.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/RemoteControl.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/RemoteControl.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/RemoteControl.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/TaskManager.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/TaskManager.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/TaskManager.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/TaskManager.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/WiFiManagement.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/WiFiManagement.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/WiFiManagement.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/WiFiManagement.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/WindowsErrorReporting.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/WindowsErrorReporting.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/WindowsErrorReporting.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/WindowsErrorReporting.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/WindowsPerformanceRecorder.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/WindowsPerformanceRecorder.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Core/WindowsPerformanceRecorder.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Core/WindowsPerformanceRecorder.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/DevicePortal.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/DevicePortal.cs
similarity index 87%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/DevicePortal.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/DevicePortal.cs
index 2deeda13..1463a667 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/DevicePortal.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/DevicePortal.cs
@@ -5,27 +5,18 @@
//----------------------------------------------------------------------------------------------
using System;
-using System.Collections.Generic;
using System.IO;
-#if !WINDOWS_UWP
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
+using System.Net.Security;
+#if NETFRAMEWORK_46
using System.Reflection;
-#endif // !WINDOWS_UWP
-#if WINDOWS_UWP
-using System.Runtime.InteropServices.WindowsRuntime;
-#endif // WINDOWS_UWP
-#if !WINDOWS_UWP
+#endif
+using System.Runtime.Serialization;
using System.Security.Cryptography.X509Certificates;
-#endif // !WINDOWS_UWP
using System.Threading;
using System.Threading.Tasks;
-#if WINDOWS_UWP
-using Windows.Security.Cryptography.Certificates;
-using Windows.Web.Http;
-using Windows.Web.Http.Headers;
-#endif // WINDOWS_UWP
namespace Microsoft.Tools.WindowsDevicePortal
{
@@ -59,9 +50,9 @@ public partial class DevicePortal
///
/// Device connection object.
///
- private IDevicePortalConnection deviceConnection;
-#if !WINDOWS_UWP
+ private readonly IDevicePortalConnection deviceConnection;
+#if NETFRAMEWORK_46
// Enable/disable useUnsafeHeaderParsing.
// See https://social.msdn.microsoft.com/Forums/en-US/ff098248-551c-4da9-8ba5-358a9f8ccc57/how-do-i-enable-useunsafeheaderparsing-from-code-net-20?forum=netfxnetcom
private static bool ToggleAllowUnsafeHeaderParsing(bool enable)
@@ -79,6 +70,7 @@ private static bool ToggleAllowUnsafeHeaderParsing(bool enable)
return true;
}
+#endif
///
/// Initializes static members of the class.
@@ -86,20 +78,30 @@ private static bool ToggleAllowUnsafeHeaderParsing(bool enable)
static DevicePortal()
{
System.Net.ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
+#if NETFRAMEWORK_46
if (!ToggleAllowUnsafeHeaderParsing(true))
{
Console.WriteLine("Failed to enable useUnsafeHeaderParsing");
}
+#endif
}
-#endif
///
/// Initializes a new instance of the class.
///
/// Implementation of a connection object.
public DevicePortal(IDevicePortalConnection connection)
+ : this(connection, (a, b) => new HttpClientWrapper(a, b))
+ {
+ }
+
+ internal DevicePortal(IDevicePortalConnection connection,
+ Func, IHttpClient> createHttpClient,
+ IWebSocketFactory webSocketFactory = null)
{
this.deviceConnection = connection;
+ this.HttpClient = createHttpClient(connection.Credentials, this.ServerCertificateValidation);
+ this.WebSockets = webSocketFactory ?? new DefaultWebSocketFactory();
}
///
@@ -141,10 +143,7 @@ public enum HttpMethods
///
/// Gets the device address.
///
- public string Address
- {
- get { return this.deviceConnection.Connection.Authority; }
- }
+ public string Address => this.deviceConnection.Connection.Authority;
///
/// Gets the status code for establishing our connection.
@@ -167,46 +166,32 @@ public string ConnectionFailedDescription
///
/// Gets the device operating system family.
///
- public string DeviceFamily
- {
- get
- {
- return (this.deviceConnection.Family != null) ? this.deviceConnection.Family : string.Empty;
- }
- }
+ public string DeviceFamily => this.deviceConnection.Family ?? string.Empty;
///
/// Gets the operating system version.
///
- public string OperatingSystemVersion
- {
- get
- {
- return (this.deviceConnection.OsInfo != null) ? this.deviceConnection.OsInfo.OsVersionString : string.Empty;
- }
- }
+ public string OperatingSystemVersion => this.deviceConnection.OsInfo?.OsVersionString ?? string.Empty;
///
/// Gets the device platform.
///
- public DevicePortalPlatforms Platform
- {
- get
- {
- return (this.deviceConnection.OsInfo != null) ? this.deviceConnection.OsInfo.Platform : DevicePortalPlatforms.Unknown;
- }
- }
+ public DevicePortalPlatforms Platform => this.deviceConnection.OsInfo?.Platform ?? DevicePortalPlatforms.Unknown;
///
/// Gets the device platform name.
///
- public string PlatformName
- {
- get
- {
- return (this.deviceConnection.OsInfo != null) ? this.deviceConnection.OsInfo.PlatformName : "Unknown";
- }
- }
+ public string PlatformName => this.deviceConnection.OsInfo?.PlatformName ?? "Unknown";
+
+ ///
+ /// Gets the HTTP client.
+ ///
+ protected IHttpClient HttpClient { get; }
+
+ ///
+ /// Gets the web socket client.
+ ///
+ protected IWebSocketFactory WebSockets { get; }
///
/// Connects to the device pointed to by IDevicePortalConnection provided in the constructor.
@@ -218,22 +203,13 @@ public string PlatformName
/// Connect sends ConnectionStatus events to indicate the current progress in the connection process.
/// Some applications may opt to not register for the ConnectionStatus event and await on Connect.
/// Task for tracking the connect.
- [method: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1118:ParameterMustNotSpanMultipleLines", Justification = "manualCertificate param doesn't really span multiple lines, it just has a different type for UWP and .NET implementations.")]
public async Task ConnectAsync(
string ssid = null,
string ssidKey = null,
bool updateConnection = false,
-#if WINDOWS_UWP
- Certificate manualCertificate = null)
-#else
X509Certificate2 manualCertificate = null)
-#endif
{
-#if WINDOWS_UWP
- this.ConnectionHttpStatusCode = HttpStatusCode.Ok;
-#else
this.ConnectionHttpStatusCode = HttpStatusCode.OK;
-#endif // WINDOWS_UWP
string connectionPhaseDescription = string.Empty;
if (manualCertificate != null)
@@ -386,16 +362,11 @@ public async Task SaveEndpointResponseToFileAsync(
if (HttpMethods.WebSocket == httpMethod)
{
-#if WINDOWS_UWP
- WebSocket websocket = new WebSocket(this.deviceConnection, true);
-#else
- WebSocket websocket = new WebSocket(this.deviceConnection, this.ServerCertificateValidation, true);
-#endif // WINDOWS_UWP
-
+ WebSocket websocket = this.CreateWebSocket(true);
ManualResetEvent streamReceived = new ManualResetEvent(false);
Stream stream = null;
- WindowsDevicePortal.WebSocketStreamReceivedEventInternalHandler streamReceivedHandler =
+ WebSocket.StreamReceivedEventHandler streamReceivedHandler =
delegate(WebSocket sender, WebSocketMessageReceivedEventArgs args)
{
if (args.Message != null)
@@ -428,21 +399,11 @@ public async Task SaveEndpointResponseToFileAsync(
}
else if (HttpMethods.Put == httpMethod)
{
-#if WINDOWS_UWP
- HttpStreamContent streamContent = null;
-#else
StreamContent streamContent = null;
-#endif // WINDOWS_UWP
-
if (requestBody != null)
{
-#if WINDOWS_UWP
- streamContent = new HttpStreamContent(requestBody.AsInputStream());
- streamContent.Headers.ContentType = new HttpMediaTypeHeaderValue(requestBodyContentType);
-#else
streamContent = new StreamContent(requestBody);
streamContent.Headers.ContentType = new MediaTypeHeaderValue(requestBodyContentType);
-#endif // WINDOWS_UWP
}
using (Stream dataStream = await this.PutAsync(uri, streamContent))
@@ -493,6 +454,8 @@ public async Task SaveEndpointResponseToFileAsync(
}
}
+ protected WebSocket CreateWebSocket(bool sendStreams = false) => this.WebSockets.Create(this.deviceConnection, this.ServerCertificateValidation, sendStreams);
+
///
/// Sends the connection status back to the caller
///
@@ -515,5 +478,18 @@ private bool IsUsingHttps()
{
return this.deviceConnection.Connection.Scheme.Equals("https", StringComparison.OrdinalIgnoreCase);
}
+
+ #region Data contract
+
+ ///
+ /// A null response class when we don't care about the response
+ /// body.
+ ///
+ [DataContract]
+ private class NullResponse
+ {
+ }
+
+ #endregion
}
}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Events/ApplicationInstallStatus.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Events/ApplicationInstallStatus.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Events/ApplicationInstallStatus.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Events/ApplicationInstallStatus.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Events/ConnectionStatus.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Events/ConnectionStatus.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Events/ConnectionStatus.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Events/ConnectionStatus.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Events/WebSocketMessageReceivedEventArgs.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Events/WebSocketMessageReceivedEventArgs.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Events/WebSocketMessageReceivedEventArgs.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Events/WebSocketMessageReceivedEventArgs.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Exceptions/DevicePortalException.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Exceptions/DevicePortalException.cs
similarity index 90%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Exceptions/DevicePortalException.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Exceptions/DevicePortalException.cs
index be9154aa..042ddfec 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Exceptions/DevicePortalException.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Exceptions/DevicePortalException.cs
@@ -6,29 +6,19 @@
using System;
using System.IO;
-#if !WINDOWS_UWP
using System.Net;
using System.Net.Http;
-#endif // !WINDOWS_UWP
-using System.Runtime.InteropServices.WindowsRuntime;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Security;
using System.Threading.Tasks;
-#if WINDOWS_UWP
-using Windows.Foundation;
-using Windows.Storage.Streams;
-using Windows.Web.Http;
-#endif // WINDOWS_UWP
namespace Microsoft.Tools.WindowsDevicePortal
{
///
/// Base exception class for a Device Portal exception
///
-#if !WINDOWS_UWP
[Serializable]
-#endif // !WINDOWS_UWP
public class DevicePortalException : Exception
{
///
@@ -126,7 +116,6 @@ public static async Task CreateAsync(
if (responseMessage.Content != null)
{
Stream dataStream = null;
-#if !WINDOWS_UWP
using (HttpContent content = responseMessage.Content)
{
dataStream = new MemoryStream();
@@ -136,22 +125,10 @@ public static async Task CreateAsync(
// Ensure we point the stream at the origin.
dataStream.Position = 0;
}
-#else // WINDOWS_UWP
- IBuffer dataBuffer = null;
- using (IHttpContent messageContent = responseMessage.Content)
- {
- dataBuffer = await messageContent.ReadAsBufferAsync();
-
- if (dataBuffer != null)
- {
- dataStream = dataBuffer.AsStream();
- }
- }
-#endif // WINDOWS_UWP
if (dataStream != null)
{
- HttpErrorResponse errorResponse = DevicePortal.ReadJsonStream(dataStream);
+ HttpErrorResponse errorResponse = dataStream.ReadJson();
if (errorResponse != null)
{
@@ -180,7 +157,6 @@ public static async Task CreateAsync(
return error;
}
-#if !WINDOWS_UWP
///
/// Get object data override
///
@@ -191,7 +167,6 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont
{
base.GetObjectData(info, context);
}
-#endif // !WINDOWS_UWP
#region data contract
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/HolographicOs.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HoloLens/HolographicOs.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/HolographicOs.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HoloLens/HolographicOs.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/HolographicPerception.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HoloLens/HolographicPerception.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/HolographicPerception.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HoloLens/HolographicPerception.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/HolographicThermal.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HoloLens/HolographicThermal.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/HolographicThermal.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HoloLens/HolographicThermal.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/MixedRealityCapture.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HoloLens/MixedRealityCapture.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/MixedRealityCapture.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HoloLens/MixedRealityCapture.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/PerceptionSimulationPlayback.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HoloLens/PerceptionSimulationPlayback.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/PerceptionSimulationPlayback.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HoloLens/PerceptionSimulationPlayback.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/PerceptionSimulationRecording.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HoloLens/PerceptionSimulationRecording.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HoloLens/PerceptionSimulationRecording.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HoloLens/PerceptionSimulationRecording.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/HttpHeadersHelper.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/Client/HttpClientWrapper.cs
similarity index 65%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/HttpHeadersHelper.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/Client/HttpClientWrapper.cs
index 11d9527b..d575d1ec 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/HttpHeadersHelper.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/Client/HttpClientWrapper.cs
@@ -1,36 +1,24 @@
//----------------------------------------------------------------------------------------------
-//
+//
// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
//
//----------------------------------------------------------------------------------------------
-#if !WINDOWS_UWP
+using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
+using System.Net.Security;
using System.Reflection;
+using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
-#else
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Threading.Tasks;
-using Windows.Web.Http;
-using Windows.Web.Http.Headers;
-#endif // !WINDOWS_UWP
+using static Microsoft.Tools.WindowsDevicePortal.DevicePortal;
namespace Microsoft.Tools.WindowsDevicePortal
{
- ///
- /// Methods for working with Http headers.
- ///
- public partial class DevicePortal
+ internal class HttpClientWrapper : IHttpClient
{
- ///
- /// Header name for Content Type of a request body.
- ///
- private static readonly string ContentTypeHeaderName = "Content-Type";
-
///
/// Header name for a CSRF-Token.
///
@@ -46,12 +34,58 @@ public partial class DevicePortal
///
private static readonly string UserAgentValue = "WindowsDevicePortalWrapper";
+ private readonly ICredentials credentials;
+ private readonly Func serverCertificateValidation;
+
///
/// CSRF token retrieved by GET calls and used on subsequent POST/DELETE/PUT calls.
/// This token is intended to prevent a security vulnerability from cross site forgery.
///
private string csrfToken = string.Empty;
+ public HttpClientWrapper(ICredentials credentials = null, Func ServerCertificateValidation = null)
+ {
+ this.credentials = credentials;
+ this.serverCertificateValidation = ServerCertificateValidation;
+ }
+
+ public Task GetAsync(Uri uri) =>
+ this.Wrap(HttpMethods.Get, client => client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead));
+
+ public Task PostAsync(Uri uri, HttpContent content) =>
+ this.Wrap(HttpMethods.Post, client => client.PostAsync(uri, content));
+
+ public Task PutAsync(Uri uri, HttpContent content) =>
+ this.Wrap(HttpMethods.Put, client => client.PutAsync(uri, content));
+
+ public Task DeleteAsync(Uri uri) =>
+ this.Wrap(HttpMethods.Delete, client => client.DeleteAsync(uri));
+
+ private async Task Wrap(HttpMethods method, Func> func)
+ {
+ var handler = new HttpClientHandler
+ {
+ UseDefaultCredentials = false,
+ Credentials = this.credentials,
+ ServerCertificateCustomValidationCallback = this.serverCertificateValidation
+ };
+
+ using (HttpClient client = new HttpClient(handler))
+ {
+ this.ApplyHttpHeaders(client, method);
+
+ HttpResponseMessage response = await func(client).ConfigureAwait(false);
+ if (!response.IsSuccessStatusCode)
+ {
+ throw await DevicePortalException.CreateAsync(response);
+ }
+
+ this.RetrieveCsrfToken(response);
+
+ return response;
+ }
+ }
+
///
/// Applies the CSRF token to the HTTP client.
///
@@ -70,12 +104,7 @@ private void ApplyCSRFHeader(
headerValue = string.IsNullOrEmpty(this.csrfToken) ? "Fetch" : headerValue;
}
-#if WINDOWS_UWP
- HttpRequestHeaderCollection headers = client.DefaultRequestHeaders;
-#else
HttpRequestHeaders headers = client.DefaultRequestHeaders;
-#endif // WINDOWS_UWP
-
headers.Add(headerName, headerValue);
}
@@ -101,18 +130,9 @@ private void ApplyUserAgentHeader(HttpClient client)
{
string userAgentValue = UserAgentValue;
-#if WINDOWS_UWP
- Assembly asm = this.GetType().GetTypeInfo().Assembly;
- userAgentValue += "-v" + asm.GetName().Version.ToString();
- userAgentValue += "-UWP";
- HttpRequestHeaderCollection headers = client.DefaultRequestHeaders;
-#else
Assembly asm = Assembly.GetExecutingAssembly();
userAgentValue += "-v" + asm.GetName().Version.ToString();
- userAgentValue += "-dotnet";
HttpRequestHeaders headers = client.DefaultRequestHeaders;
-#endif // WINDOWS_UWP
-
headers.Add(UserAgentName, userAgentValue);
}
@@ -123,17 +143,6 @@ private void ApplyUserAgentHeader(HttpClient client)
private void RetrieveCsrfToken(HttpResponseMessage response)
{
// If the response sets a CSRF token, store that for future requests.
-#if WINDOWS_UWP
- string cookie;
- if (response.Headers.TryGetValue("Set-Cookie", out cookie))
- {
- string csrfTokenNameWithEquals = CsrfTokenName + "=";
- if (cookie.StartsWith(csrfTokenNameWithEquals))
- {
- this.csrfToken = cookie.Substring(csrfTokenNameWithEquals.Length);
- }
- }
-#else
IEnumerable cookies;
if (response.Headers.TryGetValues("Set-Cookie", out cookies))
{
@@ -146,7 +155,6 @@ private void RetrieveCsrfToken(HttpResponseMessage response)
}
}
}
-#endif
}
}
}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/Client/HttpRest.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/Client/HttpRest.cs
new file mode 100644
index 00000000..37c07292
--- /dev/null
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/Client/HttpRest.cs
@@ -0,0 +1,166 @@
+//----------------------------------------------------------------------------------------------
+//
+// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
+//
+//----------------------------------------------------------------------------------------------
+
+using System;
+using System.IO;
+using System.Net.Http;
+using System.Threading.Tasks;
+
+namespace Microsoft.Tools.WindowsDevicePortal
+{
+ internal static class HttpRest
+ {
+ ///
+ /// Submits the http get request to the specified uri.
+ ///
+ /// The HTTP client to use.
+ /// The uri to which the get request will be issued.
+ /// Response data as a stream.
+ public static async Task GetAsync(
+ IHttpClient client,
+ Uri uri)
+ {
+ MemoryStream dataStream = null;
+
+ using (HttpResponseMessage response = await client.GetAsync(uri).ConfigureAwait(false))
+ {
+ if (!response.IsSuccessStatusCode)
+ {
+ throw await DevicePortalException.CreateAsync(response);
+ }
+
+ if (response.Content == null)
+ {
+ throw new DevicePortalException(System.Net.HttpStatusCode.NoContent, "", uri);
+ }
+
+ using (HttpContent content = response.Content)
+ {
+ dataStream = new MemoryStream();
+
+ await content.CopyToAsync(dataStream).ConfigureAwait(false);
+
+ // Ensure we return with the stream pointed at the origin.
+ dataStream.Position = 0;
+ }
+ }
+
+ return dataStream;
+ }
+
+ ///
+ /// Submits the http post request to the specified uri.
+ ///
+ /// The HTTP client to use.
+ /// 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 static async Task PostAsync(
+ IHttpClient client,
+ Uri uri,
+ HttpContent requestContent)
+ {
+ MemoryStream responseDataStream = null;
+
+ using (HttpResponseMessage response = await client.PostAsync(uri, requestContent).ConfigureAwait(false))
+ {
+ if (!response.IsSuccessStatusCode)
+ {
+ throw await DevicePortalException.CreateAsync(response);
+ }
+
+ if (response.Content != null)
+ {
+ using (HttpContent responseContent = response.Content)
+ {
+ responseDataStream = new MemoryStream();
+
+ await responseContent.CopyToAsync(responseDataStream).ConfigureAwait(false);
+
+ // Ensure we return with the stream pointed at the origin.
+ responseDataStream.Position = 0;
+ }
+ }
+ }
+
+ return responseDataStream;
+ }
+
+ ///
+ /// Submits the http put request to the specified uri.
+ ///
+ /// The HTTP client to use.
+ /// The uri to which the put request will be issued.
+ /// The HTTP content comprising the body of the request.
+ /// Task tracking the PUT completion.
+ public static async Task PutAsync(
+ IHttpClient client,
+ Uri uri,
+ HttpContent body = null)
+ {
+ MemoryStream dataStream = null;
+
+ using (HttpResponseMessage response = await client.PutAsync(uri, body).ConfigureAwait(false))
+ {
+ if (!response.IsSuccessStatusCode)
+ {
+ throw await DevicePortalException.CreateAsync(response);
+ }
+
+ if (response.Content != null)
+ {
+ using (HttpContent content = response.Content)
+ {
+ dataStream = new MemoryStream();
+
+ await content.CopyToAsync(dataStream).ConfigureAwait(false);
+
+ // Ensure we return with the stream pointed at the origin.
+ dataStream.Position = 0;
+ }
+ }
+ }
+
+ return dataStream;
+ }
+
+ ///
+ /// Submits the http delete request to the specified uri.
+ ///
+ /// The HTTP client to use.
+ /// The uri to which the delete request will be issued.
+ /// Task tracking HTTP completion
+ public static async Task DeleteAsync(
+ IHttpClient client,
+ Uri uri)
+ {
+ MemoryStream dataStream = null;
+
+ using (HttpResponseMessage response = await client.DeleteAsync(uri).ConfigureAwait(false))
+ {
+ if (!response.IsSuccessStatusCode)
+ {
+ throw await DevicePortalException.CreateAsync(response);
+ }
+
+ if (response.Content != null)
+ {
+ using (HttpContent content = response.Content)
+ {
+ dataStream = new MemoryStream();
+
+ await content.CopyToAsync(dataStream).ConfigureAwait(false);
+
+ // Ensure we return with the stream pointed at the origin.
+ dataStream.Position = 0;
+ }
+ }
+ }
+
+ return dataStream;
+ }
+ }
+}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/Client/IHttpClient.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/Client/IHttpClient.cs
new file mode 100644
index 00000000..5957a9a5
--- /dev/null
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/Client/IHttpClient.cs
@@ -0,0 +1,48 @@
+//----------------------------------------------------------------------------------------------
+//
+// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
+//
+//----------------------------------------------------------------------------------------------
+
+using System;
+using System.Net.Http;
+using System.Threading.Tasks;
+
+namespace Microsoft.Tools.WindowsDevicePortal
+{
+ ///
+ /// An interface corresponding to .
+ ///
+ public interface IHttpClient
+ {
+ ///
+ /// Submits the http get request to the specified uri.
+ ///
+ /// The uri to which the get request will be issued.
+ /// Response data message.
+ Task GetAsync(Uri uri);
+
+ ///
+ /// 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
+ Task PostAsync(Uri uri, HttpContent content);
+
+ ///
+ /// Submits the http put request to the specified uri.
+ ///
+ /// The uri to which the put request will be issued.
+ /// The HTTP content comprising the body of the request.
+ /// Task tracking the PUT completion.
+ Task PutAsync(Uri uri, HttpContent content);
+
+ ///
+ /// Submits the http delete request to the specified uri.
+ ///
+ /// The uri to which the delete request will be issued.
+ /// Task tracking HTTP completion
+ Task DeleteAsync(Uri uri);
+ }
+}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/ResponseHelpers.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/ResponseHelpers.cs
similarity index 91%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/ResponseHelpers.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/ResponseHelpers.cs
index 65b2fa05..f441b844 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/HttpRest/ResponseHelpers.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/ResponseHelpers.cs
@@ -10,13 +10,14 @@
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text.RegularExpressions;
+using static Microsoft.Tools.WindowsDevicePortal.DevicePortal;
namespace Microsoft.Tools.WindowsDevicePortal
{
///
/// Methods for working with Http responses.
///
- public partial class DevicePortal
+ public static class ResponseHelpers
{
///
/// The prefix for the JSON formatting error.
@@ -35,7 +36,7 @@ public partial class DevicePortal
/// The stream that contains the JSON message to be checked.
/// Optional settings for JSON serialization.
/// Read data
- public static T ReadJsonStream(Stream dataStream, DataContractJsonSerializerSettings settings = null)
+ public static T ReadJson(this Stream dataStream, DataContractJsonSerializerSettings settings = null)
{
T data = default(T);
object response = null;
@@ -97,18 +98,5 @@ private static void JsonFormatCheck(Stream jsonStream)
jsonStream.Seek(0, SeekOrigin.Begin);
}
}
-
- #region Data contract
-
- ///
- /// A null response class when we don't care about the response
- /// body.
- ///
- [DataContract]
- private class NullResponse
- {
- }
-
- #endregion
}
}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestDelete.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestDelete.cs
index 12e85497..707aa700 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestDelete.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestDelete.cs
@@ -13,53 +13,49 @@
namespace Microsoft.Tools.WindowsDevicePortal
{
///
- /// .net 4.x implementation of HTTP DeleteAsync
+ /// HTTP DELETE Wrapper
///
public partial class DevicePortal
{
///
- /// Submits the http delete request to the specified uri.
+ /// Calls the specified API with the provided payload. This signature leaves
+ /// off the optional response so callers who don't need a response body
+ /// don't need to specify a type for it.
///
- /// The uri to which the delete request will be issued.
- /// Task tracking HTTP completion
- public async Task DeleteAsync(Uri uri)
+ /// The relative portion of the uri path that specifies the API to call.
+ /// The query string portion of the uri path that provides the parameterized data.
+ /// Task tracking the HTTP completion.
+ public async Task DeleteAsync(
+ string apiPath,
+ string payload = null)
{
- MemoryStream dataStream = null;
-
- WebRequestHandler requestSettings = new WebRequestHandler();
- requestSettings.UseDefaultCredentials = false;
- requestSettings.Credentials = this.deviceConnection.Credentials;
- requestSettings.ServerCertificateValidationCallback = this.ServerCertificateValidation;
-
- using (HttpClient client = new HttpClient(requestSettings))
- {
- this.ApplyHttpHeaders(client, HttpMethods.Delete);
-
- using (HttpResponseMessage response = await client.DeleteAsync(uri).ConfigureAwait(false))
- {
- if (!response.IsSuccessStatusCode)
- {
- throw await DevicePortalException.CreateAsync(response);
- }
-
- this.RetrieveCsrfToken(response);
-
- if (response.Content != null)
- {
- using (HttpContent content = response.Content)
- {
- dataStream = new MemoryStream();
-
- await content.CopyToAsync(dataStream).ConfigureAwait(false);
+ await this.DeleteAsync(apiPath, payload);
+ }
- // Ensure we return with the stream pointed at the origin.
- dataStream.Position = 0;
- }
- }
- }
- }
+ ///
+ /// Calls the specified API with the provided payload.
+ ///
+ /// The type of the data for the HTTP response body (if present).
+ /// The relative portion of the uri path that specifies the API to call.
+ /// The query string portion of the uri path that provides the parameterized data.
+ /// Task tracking the HTTP completion.
+ public async Task DeleteAsync(
+ string apiPath,
+ string payload = null) where T : new()
+ {
+ Uri uri = Utilities.BuildEndpoint(
+ this.deviceConnection.Connection,
+ apiPath,
+ payload);
- return dataStream;
+ return (await this.DeleteAsync(uri)).ReadJson();
}
+
+ ///
+ /// Submits the http delete request to the specified uri.
+ ///
+ /// The uri to which the delete request will be issued.
+ /// Task tracking HTTP completion
+ public Task DeleteAsync(Uri uri) => HttpRest.DeleteAsync(this.HttpClient, uri);
}
}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestGet.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestGet.cs
index 616457b6..d4b6042c 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestGet.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestGet.cs
@@ -6,57 +6,39 @@
using System;
using System.IO;
-using System.Net.Http;
using System.Threading.Tasks;
namespace Microsoft.Tools.WindowsDevicePortal
{
///
- /// .net 4.x implementation of HTTP GetAsync
+ /// HTTP GET Wrapper
///
public partial class DevicePortal
{
///
- /// Submits the http get request to the specified uri.
+ /// Calls the specified API with the provided payload.
///
- /// The uri to which the get request will be issued.
- /// Response data as a stream.
- public async Task GetAsync(
- Uri uri)
+ /// Return type for the GET call
+ /// The relative portion of the uri path that specifies the API to call.
+ /// The query string portion of the uri path that provides the parameterized data.
+ /// An object of the specified type containing the data returned by the request.
+ public async Task GetAsync(
+ string apiPath,
+ string payload = null) where T : new()
{
- HttpClient client = null;
- HttpResponseMessage response = null;
- try
- {
- WebRequestHandler handler = new WebRequestHandler();
- handler.UseDefaultCredentials = false;
- handler.Credentials = this.deviceConnection.Credentials;
- handler.ServerCertificateValidationCallback = this.ServerCertificateValidation;
-
- client = new HttpClient(handler);
- this.ApplyHttpHeaders(client, HttpMethods.Get);
-
- response = await client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
- if (!response.IsSuccessStatusCode)
- {
- throw await DevicePortalException.CreateAsync(response);
- }
-
- this.RetrieveCsrfToken(response);
-
- if (response.Content == null)
- {
- throw new DevicePortalException(System.Net.HttpStatusCode.NoContent, "", uri);
- }
+ Uri uri = Utilities.BuildEndpoint(
+ this.deviceConnection.Connection,
+ apiPath,
+ payload);
- return await response.Content.ReadAsStreamAsync();
- }
- catch (Exception)
- {
- response?.Dispose();
- client?.Dispose();
- throw;
- }
+ return (await this.GetAsync(uri).ConfigureAwait(false)).ReadJson();
}
+
+ ///
+ /// Submits the http get request to the specified uri.
+ ///
+ /// The uri to which the get request will be issued.
+ /// Response data as a stream.
+ public Task GetAsync(Uri uri) => HttpRest.GetAsync(this.HttpClient, uri);
}
}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestPost.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestPost.cs
index 5eec2235..d3405e95 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestPost.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestPost.cs
@@ -5,6 +5,7 @@
//----------------------------------------------------------------------------------------------
using System;
+using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
@@ -13,10 +14,77 @@
namespace Microsoft.Tools.WindowsDevicePortal
{
///
- /// .net 4.x implementation of HTTP PostAsync
+ /// HTTP POST Wrapper
///
public partial class DevicePortal
{
+ ///
+ /// Header name for Content Type of a request body.
+ ///
+ private static readonly string ContentTypeHeaderName = "Content-Type";
+
+ ///
+ /// Calls the specified API with the provided body. This signature leaves
+ /// off the optional response so callers who don't need a response body
+ /// don't need to specify a type for it.
+ ///
+ /// The relative portion of the uri path that specifies the API to call.
+ /// List of files that we want to include in the post request.
+ /// The query string portion of the uri path that provides the parameterized data.
+ /// Task tracking the POST completion.
+ public async Task PostAsync(
+ string apiPath,
+ List files,
+ string payload = null)
+ {
+ Uri uri = Utilities.BuildEndpoint(
+ this.deviceConnection.Connection,
+ apiPath,
+ payload);
+
+ var content = new HttpMultipartFileContent();
+ content.AddRange(files);
+ await this.PostAsync(uri, content);
+ }
+
+ ///
+ /// Calls the specified API with the provided body. This signature leaves
+ /// off the optional response so callers who don't need a response body
+ /// don't need to specify a type for it.
+ ///
+ /// The relative portion of the uri path that specifies the API to call.
+ /// The query string portion of the uri path that provides the parameterized data.
+ /// Task tracking the POST completion.
+ public async Task PostAsync(
+ string apiPath,
+ string payload = null)
+ {
+ await this.PostAsync(apiPath, payload);
+ }
+
+ ///
+ /// Calls the specified API with the provided payload.
+ ///
+ /// The type of the data for the HTTP response body (if present).
+ /// The relative portion of the uri path that specifies the API to call.
+ /// The query string portion of the uri path that provides the parameterized data.
+ /// Optional stream containing data for the request body.
+ /// The type of that request body data.
+ /// Task tracking the POST completion.
+ public async Task PostAsync(
+ string apiPath,
+ string payload = null,
+ Stream requestStream = null,
+ string requestStreamContentType = null) where T : new()
+ {
+ Uri uri = Utilities.BuildEndpoint(
+ this.deviceConnection.Connection,
+ apiPath,
+ payload);
+
+ return (await this.PostAsync(uri, requestStream, requestStreamContentType)).ReadJson();
+ }
+
///
/// Submits the http post request to the specified uri.
///
@@ -47,48 +115,8 @@ public async Task PostAsync(
/// 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(
+ public Task PostAsync(
Uri uri,
- HttpContent requestContent)
- {
- MemoryStream responseDataStream = null;
-
- WebRequestHandler requestSettings = new WebRequestHandler();
- requestSettings.UseDefaultCredentials = false;
- requestSettings.Credentials = this.deviceConnection.Credentials;
- requestSettings.ServerCertificateValidationCallback = this.ServerCertificateValidation;
-
- using (HttpClient client = new HttpClient(requestSettings))
- {
- client.Timeout = TimeSpan.FromMilliseconds(-1);
-
- this.ApplyHttpHeaders(client, HttpMethods.Post);
-
- using (HttpResponseMessage response = await client.PostAsync(uri, requestContent).ConfigureAwait(false))
- {
- if (!response.IsSuccessStatusCode)
- {
- throw await DevicePortalException.CreateAsync(response);
- }
-
- this.RetrieveCsrfToken(response);
-
- if (response.Content != null)
- {
- using (HttpContent responseContent = response.Content)
- {
- responseDataStream = new MemoryStream();
-
- await responseContent.CopyToAsync(responseDataStream).ConfigureAwait(false);
-
- // Ensure we return with the stream pointed at the origin.
- responseDataStream.Position = 0;
- }
- }
- }
- }
-
- return responseDataStream;
- }
+ HttpContent requestContent) => HttpRest.PostAsync(this.HttpClient, uri, requestContent);
}
}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestPut.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestPut.cs
index a85ed32b..b3fc78f2 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestPut.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/RestPut.cs
@@ -6,64 +6,82 @@
using System;
using System.IO;
-using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
+using System.Net.Http.Headers;
+using System.Runtime.Serialization.Json;
namespace Microsoft.Tools.WindowsDevicePortal
{
///
- /// .net 4.x implementation of HTTP PutAsync
+ /// HTTP PUT Wrapper
///
public partial class DevicePortal
{
///
- /// Submits the http put request to the specified uri.
+ /// Calls the specified API with the provided body. This signature leaves
+ /// off the optional response so callers who don't need a response body
+ /// don't need to specify a type for it, which also would force them
+ /// to explicitly declare their bodyData type instead of letting it
+ /// be implied implicitly.
///
- /// The uri to which the put request will be issued.
- /// The HTTP content comprising the body of the request.
+ /// The type of the data for the HTTP request body.
+ /// The relative portion of the uri path that specifies the API to call.
+ /// The data to be used for the HTTP request body.
+ /// The query string portion of the uri path that provides the parameterized data.
/// Task tracking the PUT completion.
- public async Task PutAsync(
- Uri uri,
- HttpContent body = null)
+ public async Task PutAsync(
+ string apiPath,
+ K bodyData,
+ string payload = null) where K : class
{
- MemoryStream dataStream = null;
+ await this.PutAsync(apiPath, bodyData, payload);
+ }
- WebRequestHandler requestSettings = new WebRequestHandler();
- requestSettings.UseDefaultCredentials = false;
- requestSettings.Credentials = this.deviceConnection.Credentials;
- requestSettings.ServerCertificateValidationCallback = this.ServerCertificateValidation;
+ ///
+ /// Calls the specified API with the provided body.
+ ///
+ /// The type of the data for the HTTP response body (if present).
+ /// The type of the data for the HTTP request body.
+ /// The relative portion of the uri path that specifies the API to call.
+ /// The data to be used for the HTTP request body.
+ /// The query string portion of the uri path that provides the parameterized data.
+ /// Task tracking the PUT completion, optional response body.
+ public async Task PutAsync(
+ string apiPath,
+ K bodyData = null,
+ string payload = null) where T : new()
+ where K : class
+ {
+ Uri uri = Utilities.BuildEndpoint(
+ this.deviceConnection.Connection,
+ apiPath,
+ payload);
- using (HttpClient client = new HttpClient(requestSettings))
+ StreamContent streamContent = null;
+ if (bodyData != null)
{
- this.ApplyHttpHeaders(client, HttpMethods.Put);
-
- // Send the request
- using (HttpResponseMessage response = await client.PutAsync(uri, body).ConfigureAwait(false))
- {
- if (!response.IsSuccessStatusCode)
- {
- throw await DevicePortalException.CreateAsync(response);
- }
-
- this.RetrieveCsrfToken(response);
+ // Serialize the body to a JSON stream
+ DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(K));
+ Stream stream = new MemoryStream();
+ serializer.WriteObject(stream, bodyData);
- if (response.Content != null)
- {
- using (HttpContent content = response.Content)
- {
- dataStream = new MemoryStream();
-
- await content.CopyToAsync(dataStream).ConfigureAwait(false);
-
- // Ensure we return with the stream pointed at the origin.
- dataStream.Position = 0;
- }
- }
- }
+ stream.Seek(0, SeekOrigin.Begin);
+ streamContent = new StreamContent(stream);
+ streamContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
}
- return dataStream;
+ return (await this.PutAsync(uri, streamContent)).ReadJson();
}
+
+ ///
+ /// Submits the http put request to the specified uri.
+ ///
+ /// The uri to which the put request will be issued.
+ /// The HTTP content comprising the body of the request.
+ /// Task tracking the PUT completion.
+ public Task PutAsync(
+ Uri uri,
+ HttpContent body = null) => HttpRest.PutAsync(this.HttpClient, uri, body);
}
}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/WebSockets/IWebSocketFactory.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/WebSockets/IWebSocketFactory.cs
new file mode 100644
index 00000000..156b4dcf
--- /dev/null
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/WebSockets/IWebSocketFactory.cs
@@ -0,0 +1,23 @@
+//----------------------------------------------------------------------------------------------
+//
+// Licensed under the MIT License. See LICENSE.TXT in the project root license information.
+//
+//----------------------------------------------------------------------------------------------
+
+using System;
+using System.Net.Security;
+using System.Security.Cryptography.X509Certificates;
+
+namespace Microsoft.Tools.WindowsDevicePortal
+{
+ public interface IWebSocketFactory
+ {
+ WebSocket Create(IDevicePortalConnection connection, Func serverCertificateValidationHandler, bool sendStreams = false);
+ }
+
+ internal class DefaultWebSocketFactory : IWebSocketFactory
+ {
+ public WebSocket Create(IDevicePortalConnection connection, Func serverCertificateValidationHandler, bool sendStreams = false) =>
+ new WebSocket(connection, serverCertificateValidationHandler, sendStreams);
+ }
+}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/WebSocket.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/WebSockets/WebSocket.cs
similarity index 59%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/WebSocket.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/WebSockets/WebSocket.cs
index 384cda3a..b7d254c2 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/WebSocket.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/HttpRest/WebSockets/WebSocket.cs
@@ -10,6 +10,7 @@
using System.Net.Security;
using System.Net.Sockets;
using System.Net.WebSockets;
+using System.Runtime.Serialization.Json;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading;
@@ -21,7 +22,7 @@ namespace Microsoft.Tools.WindowsDevicePortal
/// HTTP Websocket Wrapper
///
/// Return type for the websocket messages.
- internal partial class WebSocket
+ public class WebSocket
{
///
/// The hresult for the connection being reset by the peer.
@@ -33,6 +34,16 @@ internal partial class WebSocket
///
private static readonly uint MaxChunkSizeInBytes = 1024;
+ ///
+ /// The device that the is connected to.
+ ///
+ private IDevicePortalConnection deviceConnection;
+
+ ///
+ /// Indicates whether the web socket should send streams instead of parsed objects
+ ///
+ private bool sendStreams = false;
+
///
/// The that is being wrapped.
///
@@ -62,12 +73,150 @@ public WebSocket(IDevicePortalConnection connection, Func
+ /// Web socket message received event handler
+ ///
+ /// sender object
+ /// Web socket message received args
+ /// Return type for the websocket messages.
+ public delegate void MessageReceivedEventHandler(WebSocket sender, WebSocketMessageReceivedEventArgs args);
+
+ ///
+ /// Web socket stream received event handler
+ ///
+ /// sender object
+ /// Web socket message received args
+ /// Return type for the websocket.
+ public delegate void StreamReceivedEventHandler(WebSocket sender, WebSocketMessageReceivedEventArgs args);
+
+ ///
+ /// Gets or sets the message received handler.
+ ///
+ public event MessageReceivedEventHandler WebSocketMessageReceived;
+
+ ///
+ /// Gets or sets the stream received handler.
+ ///
+ public event StreamReceivedEventHandler WebSocketStreamReceived;
+
+ ///
+ /// Gets or sets a value indicating whether the web socket is connected.
+ ///
+ public bool IsConnected
+ {
+ get;
+ protected set;
+ }
+
+ ///
+ /// Gets or sets a value indicating whether the web socket is listening for messages.
+ ///
+ public bool IsListeningForMessages
+ {
+ get;
+ protected set;
+ }
+
+ ///
+ /// Initialize a connection to the websocket.
+ ///
+ /// The relative portion of the uri path that specifies the API to call.
+ /// The query string portion of the uri path that provides the parameterized data.
+ /// The task of opening the websocket connection.
+ public async Task ConnectAsync(string apiPath, string payload = null)
+ {
+ if (this.IsConnected)
+ {
+ return;
+ }
+
+ Uri uri = Utilities.BuildEndpoint(
+ this.deviceConnection.WebSocketConnection,
+ apiPath,
+ payload);
+ await this.ConnectInternalAsync(uri);
+ }
+
+ ///
+ /// Closes the connection to the websocket and stop listening for messages.
+ ///
+ /// The task of closing the websocket connection.
+ public async Task CloseAsync()
+ {
+ if (this.IsConnected)
+ {
+ if (this.IsListeningForMessages)
+ {
+ await this.StopListeningForMessagesInternalAsync();
+ }
+
+ await this.CloseInternalAsync();
+ }
+ }
+
+ ///
+ /// Starts listening for messages from the websocket. Once they are received they are parsed and the WebSocketMessageReceived event is raised.
+ ///
+ /// The task of listening for messages from the websocket.
+ public async Task ReceiveMessagesAsync()
+ {
+ if (this.IsConnected && !this.IsListeningForMessages)
+ {
+ await this.StartListeningForMessagesInternalAsync();
+ }
+ }
+
+ ///
+ /// Sends a message to the server.
+ ///
+ /// The message to send.
+ /// The task of sending a message to the websocket.
+ public async Task SendMessageAsync(string message)
+ {
+ if (this.IsConnected)
+ {
+ await this.SendMessageInternalAsync(message);
+ }
+ }
+
+ ///
+ /// Converts received stream to a parsed object and passes it to
+ /// the WebSocketMessageReceived handler. The sendstreams property can be used to
+ /// override this and send the instead via the WebSocketStreamReceived handler.
+ ///
+ /// The received stream.
+ protected void ConvertStreamToMessage(Stream stream)
+ {
+ if (stream != null && stream.Length != 0)
+ {
+ if (this.sendStreams)
+ {
+ this.WebSocketStreamReceived?.Invoke(
+ this,
+ new WebSocketMessageReceivedEventArgs(stream));
+ }
+ else
+ {
+ DataContractJsonSerializerSettings settings = new DataContractJsonSerializerSettings()
+ {
+ UseSimpleDictionaryFormat = true
+ };
+
+ T message = stream.ReadJson(settings);
+
+ this.WebSocketMessageReceived?.Invoke(
+ this,
+ new WebSocketMessageReceivedEventArgs(message));
+ }
+ }
+ }
+
///
/// Opens a connection to the specified websocket API.
///
/// The uri that the weboscket should connect to
/// The task of opening a connection to the websocket.
- private async Task ConnectInternalAsync(
+ protected virtual async Task ConnectInternalAsync(
Uri endpoint)
{
this.websocket = new ClientWebSocket();
@@ -82,8 +231,12 @@ private async Task ConnectInternalAsync(
}
this.websocket.Options.SetRequestHeader("Origin", OriginAddress);
+#if NETSTANDARD_21
+ this.websocket.Options.RemoteCertificateValidationCallback = delegate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors policyErrors)
+#else
// There is no way to set a ServerCertificateValidationCallback for a single web socket, hence the workaround.
ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors policyErrors)
+#endif
{
return this.serverCertificateValidationHandler(sender, cert, chain, policyErrors);
};
@@ -96,7 +249,7 @@ private async Task ConnectInternalAsync(
/// Closes the connection to the websocket.
///
/// The task of closing the websocket connection.
- private async Task CloseInternalAsync()
+ protected virtual async Task CloseInternalAsync()
{
await Task.Run(() =>
{
@@ -110,7 +263,7 @@ await Task.Run(() =>
/// Stops listening for messages.
///
/// The task of closing the websocket connection.
- private async Task StopListeningForMessagesInternalAsync()
+ protected virtual async Task StopListeningForMessagesInternalAsync()
{
await this.websocket.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None);
@@ -126,7 +279,7 @@ private async Task StopListeningForMessagesInternalAsync()
/// Starts listening for messages from the websocket. Once they are received they are parsed and the WebSocketMessageReceived event is raised.
///
/// The task of listening for messages from the websocket.
- private async Task StartListeningForMessagesInternalAsync()
+ protected virtual async Task StartListeningForMessagesInternalAsync()
{
await Task.Run(() =>
{
@@ -134,6 +287,19 @@ await Task.Run(() =>
});
}
+ ///
+ /// Sends a message to the server.
+ ///
+ /// The message to send.
+ /// The task of sending a message to the websocket.
+ protected virtual async Task SendMessageInternalAsync(string message)
+ {
+ byte[] bytes = Encoding.UTF8.GetBytes(message);
+ ArraySegment buffer = new ArraySegment(bytes);
+
+ await this.websocket.SendAsync(buffer, WebSocketMessageType.Text, true, CancellationToken.None);
+ }
+
///
/// Starts listening for messages from the websocket. Once they are received they are parsed and the WebSocketMessageReceived event is raised.
///
@@ -210,18 +376,5 @@ private void StartListeningForMessagesInternal()
}
});
}
-
- ///
- /// Sends a message to the server.
- ///
- /// The message to send.
- /// The task of sending a message to the websocket.
- private async Task SendMessageInternalAsync(string message)
- {
- byte[] bytes = Encoding.UTF8.GetBytes(message);
- ArraySegment buffer = new ArraySegment(bytes);
-
- await this.websocket.SendAsync(buffer, WebSocketMessageType.Text, true, CancellationToken.None);
- }
}
}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Interfaces/IDevicePortalConnection.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Interfaces/IDevicePortalConnection.cs
similarity index 96%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Interfaces/IDevicePortalConnection.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Interfaces/IDevicePortalConnection.cs
index ee679d74..7c5f7574 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Interfaces/IDevicePortalConnection.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Interfaces/IDevicePortalConnection.cs
@@ -6,10 +6,6 @@
using System;
using System.Net;
-#if !WINDOWS_UWP
-using System.Net.Security;
-using System.Security.Cryptography.X509Certificates;
-#endif
using static Microsoft.Tools.WindowsDevicePortal.DevicePortal;
namespace Microsoft.Tools.WindowsDevicePortal
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/ApplicationManager.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/ApplicationManager.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/ApplicationManager.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/ApplicationManager.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/AudioDevices.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/AudioDevices.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/AudioDevices.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/AudioDevices.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/BluetoothConnectivity.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/BluetoothConnectivity.cs
similarity index 95%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/BluetoothConnectivity.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/BluetoothConnectivity.cs
index 7a27ba55..f7a03da6 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/BluetoothConnectivity.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/BluetoothConnectivity.cs
@@ -165,11 +165,7 @@ public async Task StartListeningForBluetoothAsync(string bluetoothApi)
{
if (this.bluetoothWebSocket == null)
{
-#if WINDOWS_UWP
- this.bluetoothWebSocket = new WebSocket(this.deviceConnection);
-#else
- this.bluetoothWebSocket = new WebSocket(this.deviceConnection, this.ServerCertificateValidation);
-#endif
+ this.bluetoothWebSocket = this.CreateWebSocket();
this.bluetoothWebSocket.WebSocketMessageReceived += this.BluetoothReceivedHandler;
}
@@ -203,11 +199,7 @@ public async Task StartListeningForPairedBluetoothAsync(string bluetoothApi)
{
if (this.pairedBluetoothWebSocket == null)
{
-#if WINDOWS_UWP
- this.pairedBluetoothWebSocket = new WebSocket(this.deviceConnection);
-#else
- this.pairedBluetoothWebSocket = new WebSocket(this.deviceConnection, this.ServerCertificateValidation);
-#endif
+ this.pairedBluetoothWebSocket = this.CreateWebSocket();
this.pairedBluetoothWebSocket.WebSocketMessageReceived += this.PairedBluetoothReceivedHandler;
}
@@ -247,11 +239,7 @@ public async Task StartListeningForPairBluetoothAsync(string bluetoothApi, strin
{
if (this.pairBluetoothWebSocket == null)
{
-#if WINDOWS_UWP
- this.pairBluetoothWebSocket = new WebSocket(this.deviceConnection);
-#else
- this.pairBluetoothWebSocket = new WebSocket(this.deviceConnection, this.ServerCertificateValidation);
-#endif
+ this.pairBluetoothWebSocket = this.CreateWebSocket();
this.pairBluetoothWebSocket.WebSocketMessageReceived += this.PairBluetoothReceivedHandler;
}
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/DeviceInfo.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/DeviceInfo.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/DeviceInfo.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/DeviceInfo.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/IcsManager.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/IcsManager.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/IcsManager.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/IcsManager.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/IoTOnboarding.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/IoTOnboarding.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/IoTOnboarding.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/IoTOnboarding.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/Limpet.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/Limpet.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/Limpet.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/Limpet.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/ProcessManagement.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/ProcessManagement.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/ProcessManagement.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/ProcessManagement.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/RemoteSettings.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/RemoteSettings.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/RemoteSettings.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/RemoteSettings.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/WindowsUpdate.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/WindowsUpdate.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/IoT/WindowsUpdate.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/IoT/WindowsUpdate.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Properties/AssemblyInfo.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Properties/AssemblyInfo.cs
index 1ca9a032..3975bd05 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Properties/AssemblyInfo.cs
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Properties/AssemblyInfo.cs
@@ -4,38 +4,6 @@
//
//----------------------------------------------------------------------------------------------
-using System.Reflection;
-using System.Runtime.InteropServices;
+using System.Runtime.CompilerServices;
-// 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("WindowsDevicePortalWrapper")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("WindowsDevicePortalWrapper")]
-[assembly: AssemblyCopyright("Copyright © 2016-2017")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 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("6a9e862e-5cda-4a8a-bbc0-56e9ea921e39")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("0.9.5.1")]
-[assembly: AssemblyFileVersion("0.9.5.1")]
\ No newline at end of file
+[assembly: InternalsVisibleTo("UnitTestProject, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5c9f20ff7ece39c30b7fa912a17669e3694cccd326767086afee03ea2a07857ad706e92b2666ae08881bb7b398a88eb7f5561db9e951dff32006d35de914a7a95c39af19c7f4f1abdc63d083884d5b3bb75d3d0c74eb71b0af44d3b2c15ca83c01e2edff5b049a7fe09c3d3c745cb04c5d0de415d38db08e718d7d8e7b953c5")]
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Settings.StyleCop b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Settings.StyleCop
deleted file mode 100644
index bf8d5cc2..00000000
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Settings.StyleCop
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Utilities.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Utilities.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Utilities.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Utilities.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.csproj b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.csproj
index c64db6be..ed7d246c 100644
--- a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.csproj
+++ b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.csproj
@@ -1,36 +1,26 @@
-
-
+
+
- Debug
- AnyCPU
- {6A9E862E-5CDA-4A8A-BBC0-56E9EA921E39}
- Library
- Properties
+ net46;netstandard2.1
+ library
+
Microsoft.Tools.WindowsDevicePortal
WindowsDevicePortalWrapper
- v4.5.2
- 512
- True
- $(registry:HKEY_LOCAL_MACHINE\Software\CodePlex\StyleCop@TargetsDir)
-
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
- bin\Release\WindowsDevicePortalWrapper.xml
+ Windows Device Portal Wrapper
+
+ 0.9.7
+ Remote control of Windows 10 device for developers and device labs.
+ Microsoft
+ © Microsoft Corporation. All rights reserved.
+
+ MIT
+ WDP Windows 10 Device Portal
+ true
+ true
+
+ NETFRAMEWORK_46
+ NETSTANDARD_21
true
@@ -41,40 +31,13 @@
false
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
-
+
\ No newline at end of file
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Xbox/FiddlerSetup.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Xbox/FiddlerSetup.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Xbox/FiddlerSetup.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Xbox/FiddlerSetup.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Xbox/SmbShare.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Xbox/SmbShare.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Xbox/SmbShare.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Xbox/SmbShare.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Xbox/UserManagement.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Xbox/UserManagement.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Xbox/UserManagement.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Xbox/UserManagement.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Xbox/XboxAppDeployment.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Xbox/XboxAppDeployment.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Xbox/XboxAppDeployment.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Xbox/XboxAppDeployment.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Xbox/XboxLiveSandbox.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Xbox/XboxLiveSandbox.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Xbox/XboxLiveSandbox.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Xbox/XboxLiveSandbox.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Xbox/XboxMediaCapture.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Xbox/XboxMediaCapture.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Xbox/XboxMediaCapture.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Xbox/XboxMediaCapture.cs
diff --git a/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Xbox/XboxSettings.cs b/WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Xbox/XboxSettings.cs
similarity index 100%
rename from WindowsDevicePortalWrapper/WindowsDevicePortalWrapper.Shared/Xbox/XboxSettings.cs
rename to WindowsDevicePortalWrapper/WindowsDevicePortalWrapper/Xbox/XboxSettings.cs
diff --git a/global.json b/global.json
new file mode 100644
index 00000000..9bed05a5
--- /dev/null
+++ b/global.json
@@ -0,0 +1,5 @@
+{
+ "sdk": {
+ "version": "3.1.100"
+ }
+}