-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScriptEngine.cs
More file actions
31 lines (25 loc) · 811 Bytes
/
ScriptEngine.cs
File metadata and controls
31 lines (25 loc) · 811 Bytes
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
using Alvis.Script.Models;
namespace Alvis.Script
{
public class ScriptEngine
{
private readonly ScriptParser _parser;
public ScriptEngineOptions Options { get; }
private bool _engineIsInitialized;
public ScriptEngine(ScriptEngineOptionsBuilder options)
{
Options = options.Build();
_parser = new ScriptParser(Options);
}
public void Init()
{
_engineIsInitialized = true;
}
public void Execute(string scriptName)
{
if (!_engineIsInitialized)
throw new InvalidOperationException("Engine is not initialized. Make sure to call .Init() to start the engine first before running scripts.");
_parser.Parse(scriptName);
}
}
}