Exemplo n.º 1
0
        public void getInitialData(InitAsyncCallback callback)
        {
            Logger.log(Logger.TYPE.DEBUG, "Getting initial data...");
            Uri directorUrl = getDirectorUrl();

            dlHandler.downloadStringAsync(directorUrl,
                                          (object s, DownloadStringCompletedEventArgs e) => {
                Logger.log(Logger.TYPE.DEBUG, "Successfully retreived initial data.");
                try {
                    serverXMLCache = new ExternalAsset <XDocument>(
                        XDocument.Parse(e.Result), directorUrl.OriginalString);

                    var root = from item in serverXMLCache.get().Descendants("Server")
                               select new {
                        name       = item.Attribute("name"),
                        target     = item.Attribute("target"),
                        launchText = item.Attribute("launchText")
                    };

                    String serverName = "", targetPath = "", launchText = "";
                    foreach (var data in root)
                    {
                        serverName = data.name.Value;
                        targetPath = data.target.Value;
                        launchText = data.launchText.Value;
                        break;
                    }

                    callback.onSuccess(serverName, targetPath, launchText);
                }
                catch (Exception ex) {
                    Logger.log(Logger.TYPE.ERROR, "Was unable to parse server XML: "
                               + ex.Message + ex.StackTrace + " URL: " + directorUrl.OriginalString);

                    callback.onFailure();
                }
            });
        }
Exemplo n.º 2
0
        public void getInitialData(InitAsyncCallback callback)
        {
            Logger.log(Logger.TYPE.DEBUG, "Getting initial data...");
            Uri directorUrl = getDirectorUrl();

            dlHandler.downloadStringAsync(directorUrl,
                (object s, DownloadStringCompletedEventArgs e) => {
                Logger.log(Logger.TYPE.DEBUG, "Successfully retreived initial data.");
                try {
                    serverXMLCache = new ExternalAsset<XDocument>(
                        XDocument.Parse(e.Result), directorUrl.OriginalString);

                    var root = from item in serverXMLCache.get().Descendants("Server")
                        select new {
                            name = item.Attribute("name"),
                            target = item.Attribute("target"),
                            launchText = item.Attribute("launchText")
                        };

                    String serverName = "", targetPath = "", launchText = "";
                    foreach (var data in root) {
                        serverName = data.name.Value;
                        targetPath = data.target.Value;
                        launchText = data.launchText.Value;
                        break;
                    }

                    callback.onSuccess(serverName, targetPath, launchText);
                }
                catch(Exception ex) {
                    Logger.log(Logger.TYPE.ERROR, "Was unable to parse server XML: "
                        + ex.Message + ex.StackTrace + " URL: " + directorUrl.OriginalString);

                    callback.onFailure();
                }
            });
        }