-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBitFieldGenerator.cs
31 lines (27 loc) · 1.09 KB
/
BitFieldGenerator.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
using System;
using System.IO;
namespace BitFields.CodeGeneration
{
public static class BitFieldGenerator
{
public static void Generate(string templatePath, string outputDir, string extention, int maxWords = 8)
{
const string FileTypeToken = @"${TYPE}";
const string WordCountToken = @"${WORDCOUNT}";
const string BitCountToken = @"${BITCOUNT}";
for (var i = 1; i <= maxWords; i++)
{
var template = File.ReadAllText(templatePath);
var type = $"BitField{32*i}";
var wordCount = $"{i}";
var bitCount = $"{32*i}";
var fileContents = template
.Replace(FileTypeToken, type)
.Replace(WordCountToken, wordCount)
.Replace(BitCountToken, bitCount);
File.WriteAllText(outputDir + type + extention, fileContents);
Console.WriteLine($"Generated File: {type}");
}
}
}
}