Repository navigation
Expand file tree
/
Copy pathTempDirectoryWorkloadManifestProvider.cs
More file actions
59 lines (51 loc) · 2.34 KB
/
Copy pathTempDirectoryWorkloadManifestProvider.cs
File metadata and controls
59 lines (51 loc) · 2.34 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace Microsoft.NET.Sdk.WorkloadManifestReader
{
public class TempDirectoryWorkloadManifestProvider : IWorkloadManifestProvider
{
private readonly string _manifestsPath;
private readonly string _sdkVersionBand;
public TempDirectoryWorkloadManifestProvider(string manifestsPath, string sdkFeatureBand)
{
_manifestsPath = manifestsPath;
_sdkVersionBand = sdkFeatureBand;
}
public void RefreshWorkloadManifests() { }
public IEnumerable<ReadableWorkloadManifest> GetManifests()
{
foreach (var workloadManifestDirectory in GetManifestDirectories())
{
string? workloadManifestPath = Path.Combine(workloadManifestDirectory, "WorkloadManifest.json");
var manifestId = Path.GetFileName(workloadManifestDirectory);
int index = manifestId.IndexOf(".Manifest", StringComparison.OrdinalIgnoreCase);
if (index >= 0)
{
manifestId = manifestId.Substring(0, index);
}
yield return new(
manifestId,
workloadManifestDirectory,
workloadManifestPath,
_sdkVersionBand,
string.Empty, // The version here isn't used.
() => File.OpenRead(workloadManifestPath),
() => WorkloadManifestReader.TryOpenLocalizationCatalogForManifest(workloadManifestPath)
);
}
}
public IEnumerable<string> GetManifestDirectories()
{
if (Directory.Exists(_manifestsPath))
{
foreach (var workloadManifestDirectory in Directory.EnumerateDirectories(_manifestsPath))
{
yield return workloadManifestDirectory;
}
}
}
public string GetSdkFeatureBand() => _sdkVersionBand;
public IWorkloadManifestProvider.WorkloadVersionInfo GetWorkloadVersion() => new IWorkloadManifestProvider.WorkloadVersionInfo(_sdkVersionBand.ToString() + ".2");
public Dictionary<string, WorkloadSet> GetAvailableWorkloadSets() => new();
}
}