Represents the domain struct representation for the templates.
Ejemplo n.º 1
0
        /// <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 = Templates.GetTemplate(typeof(SvoStruct));
            var templateJavaScript = Templates.GetTemplate(typeof(SvoStruct), "_JavaScript");
            var templateTypeConverter = Templates.GetTemplate(typeof(SvoStruct), "_TypeConverter");
            var templateUnitTest = Templates.GetTemplate(typeof(SvoStruct), "_UnitTest");

            templateStruct.GenerateFile(input, fileStruct);
            templateJavaScript.GenerateFile(input, fileJavaScript);
            templateTypeConverter.GenerateFile(input, fileTypeConverter);
            templateUnitTest.GenerateFile(input, fileUnitTest);
        }
Ejemplo n.º 2
0
        /// <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 Exception("arguments required."); }

                var outputDir = new DirectoryInfo(args[0]);

                Type underlyingType = null;
                if (!args[1].Contains('.'))
                {
                    underlyingType = Type.GetType("System." + args[1].Substring(0, 1).ToUpperInvariant() + args[1].Substring(1));
                }
                else
                {
                    underlyingType = Type.GetType(args[1]);
                }

                if (underlyingType == null) { throw new ArgumentException("Could not resolve the underlying type."); }

                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);
            }
        }