forked from scriptcs-contrib/scriptcs-sample-module
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSampleModule.cs
More file actions
44 lines (39 loc) · 1.18 KB
/
SampleModule.cs
File metadata and controls
44 lines (39 loc) · 1.18 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ScriptCs;
using ScriptCs.Contracts;
namespace ScriptCs.SampleModule
{
[Module("sample", Extensions = "csx")]
public class SampleModule : IModule
{
public void Initialize(IModuleConfiguration config)
{
config.LineProcessor<TestDirectiveLineProcessor>();
Console.WriteLine("SAMPLE module initialized");
}
}
public class TestDirectiveLineProcessor : DirectiveLineProcessor
{
public TestDirectiveLineProcessor()
{
Console.Write("TestDirectiveLineProcessor .ctor");
}
protected override string DirectiveName
{
get { return "test"; }
}
protected override bool ProcessLine(IFileParser parser, FileParserContext context, string line)
{
if (line.Trim(' ').StartsWith("#" + DirectiveName))
{
Console.WriteLine("TestDirectiveLineProcessor triggered : " + line);
return true;
}
return false;
}
}
}