コード例 #1
0
        private string RetrieveNetworkInfoFile()
        {
            this.SendStatusUpdate("Waiting for network information file to be written to device.");
            RemoteIsolatedStorageFile storage = null;
            int    retryCount     = 0;
            string remoteFileName = string.Empty;

            while (string.IsNullOrEmpty(remoteFileName) && retryCount < 4)
            {
                // Need sleep here to allow application to launch.
                System.Threading.Thread.Sleep(1000);
                storage = this.browserApplication.GetIsolatedStore(null);
                List <RemoteFileInfo> files = storage.GetDirectoryListing(string.Empty);
                DateTime findTimeout        = DateTime.Now.Add(TimeSpan.FromSeconds(15));
                while (DateTime.Now < findTimeout)
                {
                    foreach (RemoteFileInfo info in files)
                    {
                        if (info.Name.Contains("networkInfo.txt"))
                        {
                            remoteFileName = info.Name;
                            break;
                        }
                    }

                    if (!string.IsNullOrEmpty(remoteFileName))
                    {
                        break;
                    }

                    System.Threading.Thread.Sleep(500);
                    storage = this.browserApplication.GetIsolatedStore(null);
                    files   = storage.GetDirectoryListing(string.Empty);
                }

                retryCount++;
            }

            if (string.IsNullOrEmpty(remoteFileName))
            {
                throw new WindowsPhoneDriverException("Application was installed and launched, but did not write network info file");
            }

            this.SendStatusUpdate("Retrieving network information file from device.");
            string localFile = Path.Combine(Path.GetTempPath(), "networkInfo.txt");

            storage.ReceiveFile("networkInfo.txt", localFile, true);
            storage.DeleteFile("networkInfo.txt");
            return(localFile);
        }
コード例 #2
0
        /// <summary>
        /// The install.
        /// </summary>
        /// <param name="applicationDefinition">
        /// The application definition.
        /// </param>
        /// <returns>
        /// The <see cref="InstallationResult"/>.
        /// </returns>
        public override InstallationResult Install(ApplicationDefinition applicationDefinition)
        {
            InstallationResult result = base.Install(applicationDefinition);

            RemoteIsolatedStorageFile store = GetIsoStorage(applicationDefinition);

            if (store.FileExists(BddhostFilePath))
            {
                store.DeleteFile(BddhostFilePath);
            }

            string hostName = Dns.GetHostEntry("127.0.0.1").HostName + ":" + this.Port;

            File.WriteAllLines(BddhostFilePath, new[] { hostName });

            store.SendFile(BddhostFilePath, BddhostFilePath, true);

            return(result);
        }