Exemplo n.º 1
0
 private static void DownloadFileCompleted(FileDownload fileDownload)
 {
     var instances = DownloadInProgress[fileDownload];
     foreach (var instance in instances)
     {
         File.Copy(fileDownload.Url, instance.InstanceLocation.Path + Manager.GetSingleton.GetConfig().MinecraftFolderPath + fileDownload.Name + ".jar");
     }
 }
Exemplo n.º 2
0
        private void RunThread()
        {
            while (IsRunning)
            {
                _currentFile = _downloadManager.Files.Dequeue();

                if (!_currentFile.Equals(default(FileDownload)))
                {
                    _client.DownloadFile(_currentFile.Url, GetCachePath() + _currentFile.Name);
                }
            }

        }
Exemplo n.º 3
0
        public static void GetFile(Instance instance)
        {
            Directory.CreateDirectory(GetCachePath());

            var file = GetCachePath() + instance.Version.Version + ".jar";
            if (!File.Exists(file))
            {
                var fileStruct = new FileDownload() { Name = instance.Version.Version + ".jar", Url = instance.Version.GetClientUrl(), DownloadFileCompleted = DownloadFileCompleted};
                if (DownloadInProgress.ContainsKey(fileStruct))
                {
                    var value = DownloadInProgress[fileStruct];
                    value.Add(instance);
                    DownloadInProgress[fileStruct] = value;
                }
                else
                {
                    var instances = new List<Instance> {instance};
                    DownloadInProgress.Add(fileStruct, instances);
                    Manager.GetSingleton.DownloadManager.Files.Enqueue(fileStruct);
                }                
            }
        }