Template-engine that uses C# scripts to generate .cs files. Usage
ExampleTemplateC# Edit|Remove csharp#r "System.Core"using System;using System.Collections.Generic;using System.Linq;var powers = Enumerable.Range(10, 5);$@"// Generation time: {DateTime.Now}namespace {Namespace}{{ public static class QuickMath {{ { string.Join ( Environment.NewLine, powers.Select(i => $@"public static double TwoToThePowerOf{i} => {Math.Pow(2, i)};") ) } }}}}" #r "System.Core" using System; using System.Collections.Generic; using System.Linq; var powers = Enumerable.Range(10, 5); $@"// Generation time: {DateTime.Now} namespace {Namespace} {{ public static class QuickMath {{ { string.Join ( Environment.NewLine, powers.Select(i => $@"public static double TwoToThePowerOf{i} => {Math.Pow(2, i)};") ) } }} }}" Result (formatted - to not hurt your eyes)C# Edit|Remove csharp// Generation time: 4/19/2016 6:44:36 AMnamespace MathLib{ public static class QuickMath { public static double TwoToThePowerOf10 => 1024; public static double TwoToThePowerOf11 => 2048; public static double TwoToThePowerOf12 => 4096; public static double TwoToThePowerOf13 => 8192; public static double TwoToThePowerOf14 => 16384; }} // Generation time: 4/19/2016 6:44:36 AM namespace MathLib { public static class QuickMath { public static double TwoToThePowerOf10 => 1024; public static double TwoToThePowerOf11 => 2048; public static double TwoToThePowerOf12 => 4096; public static double TwoToThePowerOf13 => 8192; public static double TwoToThePowerOf14 => 16384; } } |