-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodebase.cs
37 lines (30 loc) · 917 Bytes
/
Codebase.cs
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
using EnsureThat;
using System;
using System.IO;
namespace Silhouette
{
public class Codebase
{
public string Prefix { get; private set; }
public Codebase(string prefix)
{
Prefix = EnsureArg.IsNotNull(prefix);
}
public void CreateFolder(string path)
{
Directory.CreateDirectory(path);
}
public void Generate<T>(string filename)
{
Console.WriteLine($"Generating {filename}...");
dynamic template = Activator.CreateInstance(typeof(T));
if (template != null)
{
template.Session = new Microsoft.VisualStudio.TextTemplating.TextTemplatingSession();
template.Session["Prefix"] = Prefix;
template.Initialize();
File.WriteAllText(filename, template?.TransformText());
}
}
}
}