namespace Scripty.Core
{
using System;
using System.IO;
public class ScriptSource
{
public string FilePath { get; }
public string Code { get; }
///
/// Initializes a new instance of the class.
///
///
/// Script source needs to have file pathing in addition to the code in
/// order to report diagnostics correctly.
///
/// The file path.
/// The code.
///
/// Value cannot be null or empty - filePath
/// or
/// The file path must be rooted - filePath
///
/// code
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;
}
}
}