PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/platform/wp8/RhoAppRunner/Program.cs

https://github.com/abmahmoodi/rhodes
C# | 117 lines | 61 code | 17 blank | 39 comment | 10 complexity | 7e82f8a7d215a7cb8c8517b0a179d0ee MD5 | raw file
Possible License(s): GPL-2.0, CC-BY-SA-3.0, MIT
  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.Length < 5)
  45. {
  46. Console.WriteLine("Invalid parameters");
  47. return;
  48. }
  49. if (args[4] == "dev")
  50. useEmulator = false;
  51. if (useEmulator)
  52. // WP8Device = WP8SDK.GetDevices().First(d => d.Name.StartsWith("Windows Phone Emulator") || d.Name.StartsWith("Windows Phone 8 Emulator"));
  53. WP8Device = WP8SDK.GetDevices().First(d => d.Name.StartsWith("Emulator WVGA"));
  54. else
  55. WP8Device = WP8SDK.GetDevices().First(d => d.Name.StartsWith("Windows Phone Device") || d.Name.StartsWith("Windows Phone 8 Device") || d.Name.StartsWith("Device"));
  56. Console.WriteLine("Connecting to Windows Phone 8 Emulator/Device...");
  57. WP8Device.Connect();
  58. Console.WriteLine("Windows Phone 8 Emulator/Device Connected...");
  59. Guid appID = new Guid(args[0]);
  60. RemoteApplication app;
  61. if (WP8Device.IsApplicationInstalled(appID))
  62. {
  63. Console.WriteLine("Updating sample XAP to Windows Phone 8 Emulator/Device...");
  64. app = WP8Device.GetApplication(appID);
  65. if (args.Length == 6)
  66. {
  67. var remoteIso = app.GetIsolatedStore();
  68. string targetDesktopFilePath = @args[5];
  69. remoteIso.ReceiveFile("rho/rholog.txt", targetDesktopFilePath, true);
  70. return;
  71. }
  72. app.Uninstall();
  73. /* app.UpdateApplication(args[1],
  74. args[2],
  75. args[3]);
  76. Console.WriteLine("Sample XAP Updated on Windows Phone 8 Emulator/Device...");
  77. Console.WriteLine("Launching sample app on Windows Phone 8 Emulator...");
  78. //app.Launch();
  79. Console.WriteLine("Launched sample app on Windows Phone 8 Emulator...");*/
  80. //var remoteIso = app.GetIsolatedStore();
  81. //bool result = remoteIso.FileExists("rholog.txt");
  82. //result = remoteIso.FileExists("rho/apps/app/loading.png");
  83. //return;
  84. }
  85. Console.WriteLine("Installing sample XAP to Windows Phone 8 Emulator/Device...");
  86. app = WP8Device.InstallApplication(
  87. appID,
  88. appID,
  89. args[1],
  90. args[2],
  91. args[3]);
  92. Console.WriteLine("Sample XAP installed to Windows Phone 8 Emulator...");
  93. Console.WriteLine("Launching sample app on Windows Phone 8 Emulator...");
  94. app.Launch();
  95. Console.WriteLine("Launched sample app on Windows Phone 8 Emulator...");
  96. }
  97. }
  98. }