コード例 #1
0
        public Spawnset DownloadSpawnset(string fileName)
        {
            string url = UrlUtils.ApiGetSpawnset(fileName);

            try
            {
                Spawnset spawnset;

                using (TimeoutWebClient client = new TimeoutWebClient(Timeout))
                    using (Stream stream = new MemoryStream(client.DownloadData(url)))
                        if (!Spawnset.TryParse(stream, out spawnset))
                        {
                            App.Instance.ShowError("Error parsing file", "Could not parse file.");
                        }

                return(spawnset);
            }
            catch (WebException ex)
            {
                App.Instance.ShowError("Error downloading file", $"Could not connect to '{url}'.", ex);

                return(null);
            }
            catch (Exception ex)
            {
                App.Instance.ShowError("Unexpected error", "An unexpected error occurred.", ex);

                return(null);
            }
        }