-
Notifications
You must be signed in to change notification settings - Fork 368
Expand file tree
/
Copy pathLoadLineProcessor.cs
More file actions
42 lines (31 loc) · 1.13 KB
/
LoadLineProcessor.cs
File metadata and controls
42 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
39
40
41
42
using System;
using ScriptCs.Contracts;
namespace ScriptCs
{
public interface ILoadLineProcessor : ILineProcessor
{
}
public class LoadLineProcessor : DirectiveLineProcessor, ILoadLineProcessor
{
private readonly IFileSystem _fileSystem;
public LoadLineProcessor(IFileSystem fileSystem)
{
Guard.AgainstNullArgument("fileSystem", fileSystem);
_fileSystem = fileSystem;
}
protected override string DirectiveName => "load";
protected override BehaviorAfterCode BehaviorAfterCode => BehaviorAfterCode.Throw;
protected override bool ProcessLine(IFileParser parser, FileParserContext context, string line)
{
Guard.AgainstNullArgument("parser", parser);
var argument = GetDirectiveArgument(line);
var filePath = Environment.ExpandEnvironmentVariables(argument);
var fullPath = _fileSystem.GetFullPath(filePath);
if (!string.IsNullOrWhiteSpace(fullPath))
{
parser.ParseFile(fullPath, context);
}
return true;
}
}
}