void WriteAssignments(Message message, CodeWriter writer) { foreach (var member in message.Members) { writer.WriteLine("{0} = {1};", GeneratorUtil.MemberCase(member.Name), GeneratorUtil.ParameterCase(member.Name)); } }
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)); }
void WriteMembers(Message message, CodeWriter writer) { var idx = 1; foreach (var member in message.Members) { writer.WriteLine(MemberTemplate, idx, member.Type, GeneratorUtil.MemberCase(member.Name)); idx += 1; } }
void WriteParameters(Message message, CodeWriter writer) { var first = true; foreach (var member in message.Members) { if (first) { first = false; } else { writer.Write(", "); } writer.Write("{0} {1}", member.Type, GeneratorUtil.ParameterCase(member.Name)); } }