コード例 #1
0
        /// <summary>
        /// Call when you are ready to pull down the data associated with this object
        /// </summary>
        public void Update(bool force = false)
        {
            if (!force && (Opened || (RemoteFile != null && !RemoteFile.IsDirectory())))
            {
                return;
            }

            // if we are forcing an update then the assumption is that we want an update
            // of either the current item or its container. If this is not a directory and
            // we have been forced, force an update on the parent
            if (force && !IsApplication && (RemoteFile != null && !RemoteFile.IsDirectory()))
            {
                if (this.Parent != null)
                {
                    this.Parent.Update(force: true);
                }

                return;
            }

            Children.Clear();

            //Opened = true;
            Opened = true;

            IRemoteIsolatedStorageFile remoteIso = _remoteStore;

            if (remoteIso == null)
            {
                if (RemoteApp.InstanceID == Guid.Empty)
                {
                    // 8.1
                    UpdateModern(force);
                    return;
                }
                else
                {
                    remoteIso = RemoteApp.GetIsolatedStore("Local");
                }
            }

            List <IRemoteFileInfo> remoteFiles;

            try
            {
                if (remoteIso != null)
                {
                    remoteFiles = remoteIso.GetDirectoryListing(_path);

                    foreach (IRemoteFileInfo remoteFile in remoteFiles)
                    {
                        Children.Add(new RemoteAppIsoStoreItem(_appEx, remoteFile, remoteIso, this));
                    }
                }
            }
            catch (FileNotFoundException)
            {
                // no files, oh well :)
            }
        }
コード例 #2
0
        /// <summary>
        /// Construct a representation of a real remote file (or directory)
        /// </summary>
        /// <param name="app"></param>
        /// <param name="remoteFile"></param>
        private RemoteAppIsoStoreItem(RemoteApplicationEx app, IRemoteFileInfo remoteFile, IRemoteIsolatedStorageFile remoteStore, RemoteAppIsoStoreItem parent)
        {
            RemoteApp = app.RemoteApplication;

            _remoteStore = remoteStore;
            _appEx       = app;
            Parent       = parent;

            RemoteFile = remoteFile;

            // if we can't get the internal object, set it back to the default, which is remoteFile itself.
            // remoteFile only exposes a subset of properties, but these are better than none
            RemoteFileInfo = (object)remoteFile.GetInternalRemoteFileInfo() ?? (object)remoteFile;

            string name = RemoteFile.Name;

            Name = Path.GetFileName(name);

            // "\\Applications\\Data\\8531f2be-f4c3-4822-9fa6-bcc70c9d50a8\\Data\\IsolatedStore\\\\Shared"

            _path = RemoteFile.GetRelativePath();

            // Modern applications are rooted by their IsoStore object so don't need the full path
            if (_path.Contains("%"))
            {
                _path = "";
            }

            if (RemoteFile.IsDirectory())
            {
                Children.Add(new FakeRemoteAppIsoStoreItem(this));
            }
        }
コード例 #3
0
        public RemoteAppIsoStoreItem(RemoteApplicationEx app, string store)
        {
            _appEx       = app;
            Name         = store;
            _remoteStore = app.RemoteApplication.GetIsolatedStore(store);

            // these are all fake directories
            Children.Add(new FakeRemoteAppIsoStoreItem(this));

            IsRemoteStore = true;
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: ldeluca/cordova-wp8
        static void Main(string[] args)
        {
            int deviceIndex = 0;

            string iconFilePath   = "";
            string xapFilePath    = "";
            Guid   appID          = Guid.Empty;
            bool   uninstallFirst = args.Contains("-uninstall");
            bool   awaitAppClose  = args.Contains("-wait");

            string root = Directory.GetCurrentDirectory();

            if (args.Length < 1)
            {
                Usage();
                ReadWait();
                return;
            }
            else if (args.Contains("-devices"))
            {
                ListDevices();
                ReadWait();
                return;
            }
            else if (args.Length > 1 && args[1].StartsWith("-d:"))
            {
                deviceIndex = int.Parse(args[1].Substring(3));
            }

            if (Directory.Exists(args[0]))
            {
                var info = new DirectoryInfo(args[0]);
                root = info.FullName;

                try
                {
                    xapFilePath = Directory.GetFiles(root + @"\Bin\Debug", "*.xap").FirstOrDefault();
                }
                catch (DirectoryNotFoundException)
                {
                    try
                    {
                        xapFilePath = Directory.GetFiles(root + @"\Bin\Release", "*.xap").FirstOrDefault();
                    }
                    catch (DirectoryNotFoundException)
                    {
                        Log(string.Format("Error: could not find project build directoy in {0}", root), true);
                        Log("make sure your app has been successfully built before deploying.", true);
                    }
                }
            }

            if (File.Exists(args[0]))
            {
                var info = new FileInfo(args[0]);
                if (info.Extension == ".xap")
                {
                    root        = info.DirectoryName;
                    xapFilePath = info.FullName;
                }
            }

            appID = ReadAppId(root);
            if (appID == Guid.Empty)
            {
                return;    // Logging of errors is done in ReadAppId
            }

            if (File.Exists(root + @"\ApplicationIcon.png"))
            {
                iconFilePath = root + @"\ApplicationIcon.png";
            }
            else
            {
                Log(string.Format("Error: could not find application icon at {0}", root + @"\ApplicationIcon.png"), true);
                ReadWait();
                return;
            }

            if (string.IsNullOrEmpty(xapFilePath))
            {
                Log(string.Format("Error: could not find application .xap in folder {0}", root), true);
                ReadWait();
                return;
            }

            ConnectableDevice deviceConn = GetDeviceAtIndex(deviceIndex);

            Log("Connecting to device :: " + deviceConn.Id + " : " + deviceConn.Name);
            try
            {
                IDevice            device = deviceConn.Connect();
                IRemoteApplication app    = null;
                if (device.IsApplicationInstalled(appID))
                {
                    app = device.GetApplication(appID);
                    if (uninstallFirst)
                    {
                        Log("Uninstalling app on " + deviceConn.Name);
                        app.Uninstall();
                        Log("Installing app on " + deviceConn.Name);
                        app = device.InstallApplication(appID, appID, "NormalApp", iconFilePath, xapFilePath);
                    }
                    else
                    {
                        Log("Updating app on " + deviceConn.Name);
                        app.UpdateApplication("NormalApp", iconFilePath, xapFilePath);
                    }
                }
                else
                {
                    Log("Installing app on " + deviceConn.Name);
                    app = device.InstallApplication(appID, appID, "NormalApp", iconFilePath, xapFilePath);
                }

                Log("Launching app on " + deviceConn.Name);
                app.Launch();

                if (awaitAppClose)
                {
                    // wait for the app to launch
                    Thread.Sleep(4000);

                    bool isExiting = false;

                    string tempFileName = Path.GetTempFileName();

                    try
                    {
                        IRemoteIsolatedStorageFile isoFile = app.GetIsolatedStore();
                        int index = 0;
                        while (!isExiting) //app.IsRunning()) // not implemented ... wtf?
                        {
                            char[] buffer = new char[1000];

                            isoFile.ReceiveFile((object)Path.DirectorySeparatorChar + "debugOutput.txt", tempFileName, true);
                            using (StreamReader reader = System.IO.File.OpenText(tempFileName))
                            {
                                try
                                {
                                    int newLinesRead = 0;
                                    for (int lineNum = 0; ; lineNum++)
                                    {
                                        if (reader.Peek() > -1)
                                        {
                                            string str = reader.ReadLine();
                                            if (lineNum >= index)
                                            {
                                                newLinesRead++;
                                                if (str == "EXIT")
                                                {
                                                    isExiting = true;
                                                }
                                                Log(str);
                                            }
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }
                                    index += newLinesRead;
                                }
                                catch (Exception)
                                {
                                    // at end of stream most likely, no worries, ... move along.
                                }
                            }

                            Thread.Sleep(1000);
                        }

                        System.IO.File.Delete(tempFileName);
                    }
                    catch (Exception ex)
                    {
                        Log(ex.Message);
                    }
                }

                // To Stop :
                //app.TerminateRunningInstances();

                device.Disconnect();

                ReadWait();
            }
            catch (Exception ex)
            {
                Log("Error :: " + ex.Message, true);
            }
        }