static void Rebuild(string text, string fullPath) { var dsl = text; var generator = new TemplatedGenerator() { Namespace = "Sample", GenerateInterfaceForEntityWithModifiers = "?", TemplateForInterfaceName = "public interface I{0}Aggregate", TemplateForInterfaceMember = "void When({0} c);", ClassNameTemplate = @" [DataContract(Namespace = ""Sample"")] public partial class {0}", MemberTemplate = "[DataMember(Order = {0})] public {1} {2} {{ get; private set; }}", PrivateCtorTemplate = @" {0} () {{}}" }; var prefix = @" using System; using System.Collections.Generic; using System.Runtime.Serialization; "; File.WriteAllText(Path.ChangeExtension(fullPath, "cs"), prefix + GeneratorUtil.Build(dsl, generator)); }