Ejemplo n.º 1
0
        private bool Download([NotNull] string url, [NotNull] string file)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            try
            {
                var directory = Path.GetDirectoryName(file);
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                using (var client = new PlaySharpWebClient())
                {
                    Log.Debug($"Download File {url}");
                    client.DownloadFile(url, file);
                }

                return(true);
            }
            catch (Exception e)
            {
                Log.Error(e);
            }

            return(false);
        }
Ejemplo n.º 2
0
        private bool Download([NotNull] string url, [NotNull] string file)
        {
            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }

            try
            {
                var directory = Path.GetDirectoryName(file);
                if (!Directory.Exists(directory))
                {
                    Directory.CreateDirectory(directory);
                }

                using (var client = new PlaySharpWebClient())
                {
                    Log.Debug($"Download File {url}");
                    client.DownloadFile(url, file);
                }

                return true;
            }
            catch (Exception e)
            {
                Log.Error(e);
            }

            return false;
        }
Ejemplo n.º 3
0
        private string GetLatestGameVersion()
        {
            try
            {
                using (var client = new PlaySharpWebClient())
                {
                    var content = client.DownloadString(this.VersionEndpoint);
                    var json = JsonFactory.FromString<string[]>(content);
                    var latest = json.First();

                    Log.Debug($"Resolved ddragon Version {latest}");

                    return latest;
                }
            }
            catch (Exception e)
            {
                Log.Warn(e.Message);
            }

            return string.Empty;
        }