/// <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 (format == "single") { var template = new CSharp5Template(); template.Target = null; template.Model = model; if (string.IsNullOrEmpty(output)) output = @"Xamarin"; if (!Directory.Exists(output)) Directory.CreateDirectory(output); File.WriteAllText(Path.Combine(output, @"Network.cs"), template.TransformText()); } else { if (string.IsNullOrEmpty(output)) output = @"Xamarin"; if (!Directory.Exists(output)) Directory.CreateDirectory(output); var template = new CSharp5Template(); template.Model = model; // Build LZF.cs this.BuildTarget("LZF", output, template); // Build PacketReader.cs this.BuildTarget("PacketReader", output, template); // Build PacketWriter.cs this.BuildTarget("PacketWriter", output, template); // Build TcpChannelBase.cs this.BuildTarget("TcpChannelBase", output, template); // Build TcpChannel.cs this.BuildTarget("TcpChannel", output, template); //Make packets template.Target = "Packet"; foreach (var receive in model.Receives) { // Build the operation this.BuildOperation(receive, output, template); } //Make CustomType template.Target = "ComplexType"; foreach (var customType in model.CustomTypes) { // Build the type this.BuildType(customType, output, template); } } }
/// <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 (format == "single") { var template = new CSharp5Template(); template.Target = null; template.Model = model; if (string.IsNullOrEmpty(output)) { output = @"CSharp"; } if (!Directory.Exists(output)) { Directory.CreateDirectory(output); } File.WriteAllText(Path.Combine(output, @"SpikeSdk.cs"), template.TransformText()); } else { if (string.IsNullOrEmpty(output)) { output = @"CSharp"; } if (!Directory.Exists(output)) { Directory.CreateDirectory(output); } var template = new CSharp5Template(); template.Model = model; // Build LZF.cs this.BuildTarget("LZF", output, template); // Build PacketReader.cs this.BuildTarget("PacketReader", output, template); // Build PacketWriter.cs this.BuildTarget("PacketWriter", output, template); // Build TcpChannelBase.cs this.BuildTarget("TcpChannelBase", output, template); // Build TcpChannel.cs this.BuildTarget("TcpChannel", output, template); //Make packets template.Target = "Packet"; foreach (var receive in model.Receives) { // Build the operation this.BuildOperation(receive, output, template); } //Make CustomType template.Target = "ComplexType"; foreach (var customType in model.CustomTypes) { // Build the type this.BuildType(customType, output, template); } } }