-
Notifications
You must be signed in to change notification settings - Fork 1k
/
CompositeRazorProjectFileSystem.cs
48 lines (41 loc) · 1.54 KB
/
CompositeRazorProjectFileSystem.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using Microsoft.AspNetCore.Razor.Language;
namespace Microsoft.NET.Sdk.Razor.Tool
{
internal class CompositeRazorProjectFileSystem : RazorProjectFileSystem
{
public CompositeRazorProjectFileSystem(IReadOnlyList<RazorProjectFileSystem> fileSystems)
{
FileSystems = fileSystems ?? throw new ArgumentNullException(nameof(fileSystems));
}
public IReadOnlyList<RazorProjectFileSystem> FileSystems { get; }
public override IEnumerable<RazorProjectItem> EnumerateItems(string basePath)
{
foreach (var fileSystem in FileSystems)
{
foreach (var result in fileSystem.EnumerateItems(basePath))
{
yield return result;
}
}
}
public override RazorProjectItem GetItem(string path)
{
return GetItem(path, fileKind: null);
}
public override RazorProjectItem GetItem(string path, string fileKind)
{
RazorProjectItem razorProjectItem = null;
foreach (var fileSystem in FileSystems)
{
razorProjectItem = fileSystem.GetItem(path, fileKind);
if (razorProjectItem != null && razorProjectItem.Exists)
{
return razorProjectItem;
}
}
return razorProjectItem;
}
}
}