| 1 |
. |
| 2 |
|
| 3 |
|
| 4 |
using System; |
| 5 |
using System.Collections.Generic; |
| 6 |
using System.IO; |
| 7 |
using System.Linq; |
| 8 |
using System.Text; |
| 9 |
using System.Threading.Tasks; |
| 10 |
using Newtonsoft.Json.Linq; |
| 11 |
|
| 12 |
namespace Microsoft.NuGet.Build.Tasks |
| 13 |
{ |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
internal sealed class NuGetPackageObject |
| 18 |
{ |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
private readonly Lazy<string> _fullPackagePath; |
| 25 |
|
| 26 |
public NuGetPackageObject(string id, string version, Func<string> fullPackagePathGenerator, JObject targetObject, JObject libraryObject) |
| 27 |
{ |
| 28 |
Id = id; |
| 29 |
Version = version; |
| 30 |
_fullPackagePath = new Lazy<string>(fullPackagePathGenerator); |
| 31 |
TargetObject = targetObject; |
| 32 |
LibraryObject = libraryObject; |
| 33 |
} |
| 34 |
|
| 35 |
public string Id { get; } |
| 36 |
public string Version { get; } |
| 37 |
public string RelativePackagePath => (string)LibraryObject["path"]; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
public JObject TargetObject { get; } |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
public JObject LibraryObject { get; } |
| 48 |
|
| 49 |
public string GetFullPathToFile(string relativePath) |
| 50 |
{ |
| 51 |
relativePath = relativePath.Replace('/', Path.DirectorySeparatorChar); |
| 52 |
return Path.Combine(_fullPackagePath.Value, relativePath); |
| 53 |
} |
| 54 |
} |
| 55 |
} |