-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathPackageSource.cs
71 lines (58 loc) · 1.77 KB
/
PackageSource.cs
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using Microsoft.PackageManagement.Provider.Utility;
namespace Microsoft.PackageManagement.NuGetProvider
{
using System;
using System.IO;
internal class PackageSource
{
private IPackageRepository _repository;
//Parameters must be filled in during the instantiation.
internal string Name { get; set; }
internal string Location { get; set; }
internal bool Trusted { get; set; }
internal bool IsRegistered { get; set; }
internal bool IsValidated { get; set; }
internal NuGetRequest Request { get; set; }
internal IPackageRepository Repository
{
get
{
if (!IsSourceAFile)
{
return _repository ?? (_repository = PackageRepositoryFactory.Default.CreateRepository(new PackageRepositoryCreateParameters(Location, Request)));
}
return null;
}
}
internal bool IsSourceAFile
{
get
{
try
{
if (!string.IsNullOrWhiteSpace(Location) && ((!Uri.IsWellFormedUriString(Location, UriKind.Absolute) || new Uri(Location).IsFile) && File.Exists(Location)))
{
return true;
}
}
catch
{
// no worries.
}
return false;
}
}
internal string Serialized
{
get
{
if (IsRegistered && !string.IsNullOrWhiteSpace(Name))
{
return Name.ToBase64();
}
return Location.ToBase64();
}
}
}
}