コード例 #1
0
 public static string Build(string source, TemplatedGenerator generator)
 {
     var builder = new StringBuilder();
     using (var stream = new StringWriter(builder))
     using (var writer = new IndentedTextWriter(stream, "    "))
     {
         generator.Generate(GenerateContext(source), writer);
     }
     return builder.ToString();
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: AGiorgetti/lokad-cqrs
        static void Rebuild(string text, string fullPath)
        {
            var dsl = text;
            var generator = new TemplatedGenerator()
                {
                    Namespace = "SaaS",
                    GenerateInterfaceForEntityWithModifiers = "?",
                    TemplateForInterfaceName = "public interface I{0}Aggregate",
                    TemplateForInterfaceMember = "void When({0} c);",
                    ClassNameTemplate = @"

            [DataContract(Namespace = ""SaaS"")]
            public partial class {0}",
                    MemberTemplate = "[DataMember(Order = {0})] public {1} {2} {{ get; private set; }}",

                };

            var prefix = @"
            using System;
            using System.Collections.Generic;
            using System.Runtime.Serialization;

            ";
            File.WriteAllText(Path.ChangeExtension(fullPath, "cs"), prefix + GeneratorUtil.Build(dsl, generator));
        }