forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackageRepositoryFactory.cs
More file actions
38 lines (31 loc) · 1.13 KB
/
Copy pathPackageRepositoryFactory.cs
File metadata and controls
38 lines (31 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
namespace Microsoft.PackageManagement.NuGetProvider
{
using System;
using System.Net;
public class PackageRepositoryFactory : IPackageRepositoryFactory
{
private static readonly PackageRepositoryFactory _default = new PackageRepositoryFactory();
public static PackageRepositoryFactory Default
{
get { return _default;}
}
public virtual IPackageRepository CreateRepository(string packageSource, NuGetRequest request)
{
if (packageSource == null)
{
throw new ArgumentNullException("packageSource");
}
// we cannot call new uri on file path on linux because it will error out
if (System.IO.Directory.Exists(packageSource))
{
return new LocalPackageRepository(packageSource, request);
}
Uri uri = new Uri(packageSource);
if (uri.IsFile)
{
return new LocalPackageRepository(uri.LocalPath, request);
}
return new HttpClientPackageRepository(packageSource, request);
}
}
}