Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@joeriks
Created November 26, 2012 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeriks/4147064 to your computer and use it in GitHub Desktop.
Save joeriks/4147064 to your computer and use it in GitHub Desktop.
Find load syntax ( // load "module1", "module2"
// find load syntax
var scriptLines = Regex.Split(script, "\r\n|\r|\n");
var isComment = new Func<string, bool>((s) => s.TrimStart().StartsWith("//"));
var trimCommentSlashes = new Func<string, string>((s) => { return s.TrimStart().TrimStart('/').TrimStart(); });
var commandKeyWord = "load";
var loadLines = scriptLines.Where(t => isComment(t) && trimCommentSlashes(t).StartsWith(commandKeyWord + " "));
foreach (var line in loadLines)
{
var parameters = trimCommentSlashes(line).Substring(commandKeyWord.Length).TrimStart();
var modules = parameters.Split(',');
foreach (var module in modules)
{
var moduleName = module.Replace("\"", "");
ExecuteScript(moduleName);
}
}
var result = session.Execute(script) ?? "No result";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment