Skip to content

Commit

Permalink
#6 - Passing target path around.
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf committed May 14, 2018
1 parent 404f39c commit 72cc638
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/PackageManager.NuGet/Services/NuGetSearchService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Neptuo;
using NuGet.Common;
using NuGet.Protocol;
using NuGet.Protocol.Core.Types;
Expand All @@ -12,6 +13,14 @@ namespace PackageManager.Services
{
public class NuGetSearchService : ISearchService
{
public string Path { get; private set; }

public NuGetSearchService(string path)
{
Ensure.NotNull(path, "path");
Path = path;
}

private SearchOptions EnsureOptions(SearchOptions options)
{
if (options == null)
Expand Down
5 changes: 4 additions & 1 deletion src/PackageManager.UI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ protected override void OnStartup(StartupEventArgs e)

base.OnStartup(e);

MainViewModel viewModel = new MainViewModel(new NuGetSearchService(), new Views.DesignData.MockInstallService());
MainViewModel viewModel = new MainViewModel(
new NuGetSearchService(Args.Path),
new Views.DesignData.MockInstallService()
);
viewModel.Browser.Source = "https://api.nuget.org/v3/index.json";

MainWindow wnd = new MainWindow(viewModel);
Expand Down
2 changes: 2 additions & 0 deletions src/PackageManager.UI/Views/DesignData/MockInstallService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace PackageManager.Views.DesignData
{
internal class MockInstallService : IInstallService
{
public string Path => @"C:\Temp";

public bool IsInstalled(IPackage package)
=> false;
}
Expand Down
2 changes: 2 additions & 0 deletions src/PackageManager/Services/IInstallService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ namespace PackageManager.Services
{
public interface IInstallService
{
string Path { get; }

bool IsInstalled(IPackage package);
}
}
2 changes: 1 addition & 1 deletion src/PackageManager/ViewModels/Commands/InstallCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected override bool CanExecuteOverride(IPackage package)
protected override async Task ExecuteAsync(IPackage package, CancellationToken cancellationToken)
{
IPackageContent packageContent = await package.DownloadAsync(cancellationToken);
await packageContent.ExtractToAsync("C:/Temp/NuGet", cancellationToken);
await packageContent.ExtractToAsync(service.Path, cancellationToken);
}

public new void RaiseCanExecuteChanged()
Expand Down

0 comments on commit 72cc638

Please sign in to comment.