forked from daveaglick/Scripty
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptSource.cs
More file actions
47 lines (43 loc) · 1.55 KB
/
Copy pathScriptSource.cs
File metadata and controls
47 lines (43 loc) · 1.55 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
namespace Scripty.Core
{
using System;
using System.IO;
public class ScriptSource
{
public string FilePath { get; }
public string Code { get; }
/// <summary>
/// Initializes a new instance of the <see cref="ScriptSource"/> class.
/// </summary>
/// <remarks>
/// Script source needs to have file pathing in addition to the code in
/// order to report diagnostics correctly.
/// </remarks>
/// <param name="filePath">The file path.</param>
/// <param name="code">The code.</param>
/// <exception cref="ArgumentException">
/// Value cannot be null or empty - filePath
/// or
/// The file path must be rooted - filePath
/// </exception>
/// <exception cref="ArgumentNullException">code</exception>
public ScriptSource(string filePath, string code)
{
if (string.IsNullOrEmpty(filePath))
{
throw new ArgumentException("Value cannot be null or empty", nameof(filePath));
}
if (Path.IsPathRooted(filePath) == false)
{
//The Pathesolver may be able to locate this root, but the caller could use it too
throw new ArgumentException("The file path must be rooted", nameof(filePath));
}
if (code == null)
{
throw new ArgumentNullException(nameof(code));
}
FilePath = filePath;
Code = code;
}
}
}