PageRenderTime 43ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/platform/wp8/RhoAppRunner/Program.cs

https://github.com/bettertec/rhodes
C# | 99 lines | 56 code | 16 blank | 27 comment | 6 complexity | e5172265ff93c0d46b21e2589a1c8082 MD5 | raw file
Possible License(s): MIT, Apache-2.0, LGPL-2.1
  1. /*------------------------------------------------------------------------
  2. * (The MIT License)
  3. *
  4. * Copyright (c) 2008-2011 Rhomobile, Inc.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. *
  24. * http://rhomobile.com
  25. *------------------------------------------------------------------------*/
  26. using System;
  27. using System.Collections.Generic;
  28. using System.Linq;
  29. using System.Text;
  30. using System.IO;
  31. using System.Threading;
  32. using System.Reflection;
  33. using Microsoft.SmartDevice.Connectivity;
  34. namespace RhoAppRunner
  35. {
  36. class Program
  37. {
  38. static void Main(string[] args)
  39. {
  40. DatastoreManager dsmgrObj = new DatastoreManager(1033);
  41. Platform WP8SDK = dsmgrObj.GetPlatforms().Single(p => p.Name == "Windows Phone 8");
  42. bool useEmulator = true;
  43. Device WP8Device = null;
  44. if (args[4] == "dev")
  45. useEmulator = false;
  46. if (useEmulator)
  47. // WP8Device = WP8SDK.GetDevices().First(d => d.Name.StartsWith("Windows Phone Emulator") || d.Name.StartsWith("Windows Phone 8 Emulator"));
  48. WP8Device = WP8SDK.GetDevices().First(d => d.Name.StartsWith("Emulator WVGA"));
  49. else
  50. WP8Device = WP8SDK.GetDevices().First(d => d.Name.StartsWith("Windows Phone Device") || d.Name.StartsWith("Windows Phone 8 Device"));
  51. Console.WriteLine("Connecting to Windows Phone 8 Emulator/Device...");
  52. WP8Device.Connect();
  53. Console.WriteLine("Windows Phone 8 Emulator/Device Connected...");
  54. Guid appID = new Guid(args[0]);
  55. RemoteApplication app;
  56. if (WP8Device.IsApplicationInstalled(appID))
  57. {
  58. Console.WriteLine("Updating sample XAP to Windows Phone 8 Emulator/Device...");
  59. app = WP8Device.GetApplication(appID);
  60. //app.Uninstall();
  61. app.UpdateApplication(args[1],
  62. args[2],
  63. args[3]);
  64. Console.WriteLine("Sample XAP Updated on Windows Phone 8 Emulator/Device...");
  65. Console.WriteLine("Launching sample app on Windows Phone 8 Emulator...");
  66. app.Launch();
  67. Console.WriteLine("Launched sample app on Windows Phone 8 Emulator...");
  68. return;
  69. }
  70. Console.WriteLine("Installing sample XAP to Windows Phone 8 Emulator/Device...");
  71. app = WP8Device.InstallApplication(
  72. appID,
  73. appID,
  74. args[1],
  75. args[2],
  76. args[3]);
  77. Console.WriteLine("Sample XAP installed to Windows Phone 8 Emulator...");
  78. Console.WriteLine("Launching sample app on Windows Phone 8 Emulator...");
  79. app.Launch();
  80. Console.WriteLine("Launched sample app on Windows Phone 8 Emulator...");
  81. }
  82. }
  83. }