Example #1
0
        public void DownloadPackage()
        {
            var downloadResourceResult = _nugetRepository.DownloadPackageAsync(TestPackageName, true, true).Result;
            var tempLocation           = Directory.CreateDirectory("Temp\\DownloadedMod");

            Nuget.ExtractPackage(downloadResourceResult, tempLocation.FullName);

            // Check ModConfig.json exists.
            string modConfigLocation = $"{tempLocation.FullName}\\ModConfig.json";

            Assert.True(File.Exists(modConfigLocation));

            Directory.Delete(tempLocation.FullName, true);
        }
        private async void OK_Click(object sender, RoutedEventArgs e)
        {
            ViewModel.DownloadEnabled   = false;
            ViewModel.DownloadModStatus = DownloadModStatus.Downloading;

            var loaderConfig = IoC.Get <LoaderConfig>();

            foreach (var package in ViewModel.Packages)
            {
                var downloadPackage = await package.Repository.DownloadPackageAsync(package.Generic, CancellationToken.None);

                Nuget.ExtractPackage(downloadPackage, Path.Combine(loaderConfig.ModConfigDirectory, package.Generic.Identity.Id));
            }

            ViewModel.DownloadModStatus = DownloadModStatus.Default;
            ViewModel.DownloadEnabled   = false;

            this.Close();
        }
Example #3
0
 public async Task ExtractPackageAsync(string sourceFilePath, string destDirPath, IProgress <double> progress = null,
                                       CancellationToken cancellationToken = new CancellationToken())
 {
     await Task.Run(() => Nuget.ExtractPackage(sourceFilePath, destDirPath, cancellationToken), cancellationToken);
 }