Ejemplo n.º 1
0
        /// <summary>
        /// Build the model of the specified type.
        /// </summary>
        /// <param name="model">The model to build.</param>
        /// <param name="output">The output type.</param>
        /// <param name="format">The format to apply.</param>
        public override void Build(Model model, string output, string format)
        {
            if (string.IsNullOrEmpty(output))
            {
                output = @"Go";
            }

            if (!Directory.Exists(output))
            {
                Directory.CreateDirectory(output);
            }

            output = Path.Combine(output, "src/spike");
            if (!Directory.Exists(output))
            {
                Directory.CreateDirectory(output);
            }

            var template = new GoTemplate();

            template.Model = model;

            // Build packet_compressor.go
            this.BuildTarget("PacketCompressor", output, template, ConventionType.Underscore);

            // Build packet_reader.go
            this.BuildTarget("PacketReader", output, template, ConventionType.Underscore);

            // Build packet_writer.go
            this.BuildTarget("PacketWriter", output, template, ConventionType.Underscore);

            // Build tcp_channel.go
            this.BuildTarget("TcpChannel", output, template, ConventionType.Underscore);

            //Make packets
            template.Target = "Packet";
            foreach (var receive in model.Receives)
            {
                // Build the operation
                this.BuildOperation(receive, output, template, ConventionType.Underscore);
            }

            //Make CustomType
            template.Target = "ComplexType";
            foreach (var customType in model.CustomTypes)
            {
                // Build the type
                this.BuildType(customType, output, template, ConventionType.Underscore);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Build the model of the specified type.
        /// </summary>
        /// <param name="model">The model to build.</param>
        /// <param name="output">The output type.</param>
        /// <param name="format">The format to apply.</param>
        public override void Build(Model model, string output, string format)
        {
            if (string.IsNullOrEmpty(output))
                output = @"Go";

            if (!Directory.Exists(output))
                Directory.CreateDirectory(output);

            output = Path.Combine(output, "src/spike");
            if (!Directory.Exists(output))
                Directory.CreateDirectory(output);

            var template = new GoTemplate();
            template.Model = model;

            // Build packet_compressor.go
            this.BuildTarget("PacketCompressor", output, template, ConventionType.Underscore);

            // Build packet_reader.go
            this.BuildTarget("PacketReader", output, template, ConventionType.Underscore);

            // Build packet_writer.go
            this.BuildTarget("PacketWriter", output, template, ConventionType.Underscore);

            // Build tcp_channel.go
            this.BuildTarget("TcpChannel", output, template, ConventionType.Underscore);

            //Make packets
            template.Target = "Packet";
            foreach (var receive in model.Receives)
            {
                // Build the operation
                this.BuildOperation(receive, output, template, ConventionType.Underscore);
            }

            //Make CustomType
            template.Target = "ComplexType";
            foreach (var customType in model.CustomTypes)
            {
                // Build the type
                this.BuildType(customType, output, template, ConventionType.Underscore);
            }
        }