Skip to content

Commit

Permalink
Adding missing file
Browse files Browse the repository at this point in the history
  • Loading branch information
glennblock committed May 6, 2013
1 parent 32a23bc commit 2a462db
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/ScriptCs/Repl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using Common.Logging;
using ScriptCs.Contracts;

namespace ScriptCs
{
public class Repl
{
private static readonly string[] DefaultReferences = new[] { "System", "System.Core", "System.Data", "System.Data.DataSetExtensions", "System.Xml", "System.Xml.Linq" };
private static readonly string[] DefaultNamespaces = new[] { "System", "System.Collections.Generic", "System.Linq", "System.Text", "System.Threading.Tasks" };

private readonly IFileSystem _fileSystem;
private readonly IScriptEngine _scriptEngine;
private readonly ILog _logger;
private ScriptPackSession _scriptPackSession;
private IEnumerable<string> _references;

public Repl(IFileSystem fileSystem, IScriptEngine scriptEngine, ILog logger)
{
_fileSystem = fileSystem;
_scriptEngine = scriptEngine;
_logger = logger;
}

public void Initialize(IEnumerable<string> paths, IEnumerable<IScriptPack> scriptPacks)
{
_references = DefaultReferences.Union(paths);
var bin = Path.Combine(_fileSystem.CurrentDirectory, "bin");

_scriptEngine.BaseDirectory = bin;

_logger.Debug("Initializing script packs");
var scriptPackSession = new ScriptPackSession(scriptPacks);

scriptPackSession.InitializePacks();
_scriptPackSession = scriptPackSession;

}

public void Terminate()
{
_logger.Debug("Terminating packs");
_scriptPackSession.TerminatePacks();
}

public void Execute(string script)
{
_scriptEngine.Execute(script, _references, DefaultNamespaces, _scriptPackSession);
}
}
}

0 comments on commit 2a462db

Please sign in to comment.