/// <summary> Creates source code for a specific message structure and /// writes it under the specified directory. /// throws IllegalArgumentException if there is no message structure /// for this message in the normative database /// </summary> public static void make(String message, String baseDirectory, String chapter, String version) { try { SegmentDef[] segments = getSegments(message, version); //System.out.println("Making: " + message + " with " + segments.length + " segments (not writing message code - just groups)"); GroupDef group = GroupGenerator.getGroupDef(segments, null, baseDirectory, version, message); IStructureDef[] contents = group.Structures; //make base directory if (!(baseDirectory.EndsWith("\\") || baseDirectory.EndsWith("/"))) { baseDirectory = baseDirectory + "/"; } FileInfo targetDir = SourceGenerator.makeDirectory(baseDirectory + PackageManager.GetVersionPackagePath(version) + "Message"); Console.Out.WriteLine("Writing " + message + " to " + targetDir.FullName); using (StreamWriter out_Renamed = new StreamWriter(targetDir.FullName + "/" + message + ".cs")) { out_Renamed.Write(makePreamble(contents, message, chapter, version)); out_Renamed.Write(makeConstructor(contents, message, version)); for (int i = 0; i < contents.Length; i++) { string groupAccessor = GroupGenerator.makeAccessor(@group, i); out_Renamed.Write(groupAccessor); } //add implementation of model.control interface, if any out_Renamed.Write("}\r\n"); //End class out_Renamed.Write("}\r\n"); //End namespace } } catch (Exception e) { log.Error("Error while creating source code", e); log.Warn("Warning: could not write source code for message structure " + message + " - " + e.GetType().FullName + ": " + e.Message); } }