scriptcs/scriptcs — pull request #396 by khellang (2013-08-08 19:25:57+00:00)
Title: Refactored ProcessLine into ILineProcessor

Fixes #389.

Played around a bit and this is what I came up with... Now adding a custom line processor is as easy as implementing `ILineProcessor` or the abstract convenience class `DirectiveLineProcessor`:

```csharp
public class GistLineProcessor : DirectiveLineProcessor
{
protected override string DirectiveName
{
get { return "gist"; }
}

protected override bool ProcessLine(IFileParser parser, FileParserContext context, string line)
{
var gistId = GetDirectiveArgument(line);

var gistContent = DownloadGist(gistId);

parser.ParseScript(gistContent, context);

return true;
}

private static List DownloadGist(string gistId)
{
// Download Gist content...
}
}
```
and add it with the `ScriptServicesBuilder`:

new ScriptServicesBuilder(console, logger).AddLineProcessor();

By default, there's three:
- `LoadLineProcessor`
- `UsingLineProcessor`
- `ReferenceLineProcessor`

What do you think?