/// <summary>Generates code for the Single Value Object.</summary> /// <param name="dir"> /// The directory to write the files to. /// </param> /// <param name="input"> /// The input data of the Single Value Object. /// </param> public void Generate(DirectoryInfo dir, SvoStruct input) { var fileStruct = new FileInfo(Path.Combine(dir.FullName, input.ClassName + ".cs")); var fileJavaScript = new FileInfo(Path.Combine(dir.FullName, "Qowaiv." + input.ClassName + ".js")); var fileTypeConverter = new FileInfo(Path.Combine(dir.FullName, input.ClassName + "TypeConverter.cs")); var fileUnitTest = new FileInfo(Path.Combine(dir.FullName, input.ClassName + "Test.cs")); var templateStruct = RazorTemplates.Select <SvoStruct>(); var templateJavaScript = RazorTemplates.Select <SvoStruct>("_JavaScript"); var templateTypeConverter = RazorTemplates.Select <SvoStruct>("_TypeConverter"); var templateUnitTest = RazorTemplates.Select <SvoStruct>("_UnitTest"); templateStruct.GenerateFile(input, fileStruct); templateJavaScript.GenerateFile(input, fileJavaScript); templateTypeConverter.GenerateFile(input, fileTypeConverter); templateUnitTest.GenerateFile(input, fileUnitTest); }
/// <summary>Executes the program.</summary> /// <param name="args">The Arguments of the program.</param> /// <remarks> /// CodeGenerator.exe outputDir underlyingType className [longClassName] [a|an] [namespace] /// /// Example: CodeGenerator.exe C:\Temp\Qowaiv string EmailAddress "Email address" an Qowaiv /// </remarks> public static void Main(string[] args) { AppendLoggers(); try { if (args == null || args.Length < 3) { throw new ArgumentException("arguments required."); } var outputDir = new DirectoryInfo(args[0]); Type underlyingType = GetType(args[1]); var input = new SvoStruct() { ClassName = args[2], UnderlyingType = underlyingType }; if (args.Length > 3) { input.ClassLongName = args[3]; } if (args.Length > 4) { input.a = args[4].ToLower(); } if (args.Length > 5) { input.Namespace = args[5]; } var rsxGen = new QowaivCodeGenerator(); var svoGen = new SvoStructGenerator(); rsxGen.Generate(outputDir); svoGen.Generate(outputDir, input); } catch (Exception x) { log.Error(x); } }