Skip to content

Commit

Permalink
(GH-5) Interface for PackageDownloader
Browse files Browse the repository at this point in the history
Also allow overriding PackageDownloader
  • Loading branch information
ferventcoder committed Dec 18, 2016
1 parent a48c742 commit 19986e7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
<Compile Include="FileModifiers\XmlTransfomer.cs" />
<Compile Include="Http\IHttpClient.cs" />
<Compile Include="Utility\FrameworkNameEqualityComparer.cs" />
<Compile Include="Utility\IPackageDownloader.cs" />
<Compile Include="Utility\IProgressProvider.cs" />
<Compile Include="Utility\IVersionSpec.cs" />
<Compile Include="Utility\MemoryCache.cs" />
Expand Down
11 changes: 11 additions & 0 deletions src/Core/Utility/IPackageDownloader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace NuGet
{
using System;
using System.IO;

public interface IPackageDownloader : IHttpClientEvents
{
void DownloadPackage(Uri uri, IPackageMetadata package, Stream targetStream);
void DownloadPackage(IHttpClient downloadClient, IPackageName package, Stream targetStream);
}
}
10 changes: 5 additions & 5 deletions src/Core/Utility/PackageDownloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace NuGet
{
public class PackageDownloader : IHttpClientEvents
public class PackageDownloader : IPackageDownloader
{
private const string DefaultUserAgentClient = "NuGet Core";

Expand All @@ -15,7 +15,7 @@ public class PackageDownloader : IHttpClientEvents
public string CurrentDownloadPackageId
{
get;
private set;
protected set;
}

public virtual void DownloadPackage(Uri uri, IPackageMetadata package, Stream targetStream)
Expand All @@ -32,7 +32,7 @@ public virtual void DownloadPackage(Uri uri, IPackageMetadata package, Stream ta
DownloadPackage(downloadClient, package, targetStream);
}

public void DownloadPackage(IHttpClient downloadClient, IPackageName package, Stream targetStream)
public virtual void DownloadPackage(IHttpClient downloadClient, IPackageName package, Stream targetStream)
{
if (downloadClient == null)
{
Expand Down Expand Up @@ -68,12 +68,12 @@ public void DownloadPackage(IHttpClient downloadClient, IPackageName package, St
}
}

private void OnPackageDownloadProgress(ProgressEventArgs e)
protected virtual void OnPackageDownloadProgress(ProgressEventArgs e)
{
ProgressAvailable(this, e);
}

private void OnSendingRequest(object sender, WebRequestEventArgs webRequestArgs)
protected virtual void OnSendingRequest(object sender, WebRequestEventArgs webRequestArgs)
{
SendingRequest(this, webRequestArgs);
}
Expand Down

0 comments on commit 19986e7

Please sign in to comment.