protected override void Visit(SendExpressionChunk chunk) { bool automaticallyEncode = chunk.AutomaticallyEncode; if (chunk.Code.ToString().StartsWith("H(")) { automaticallyEncode = false; } this._source.WriteLine("try").WriteLine("{"); this.CodeIndent(chunk).Write("Output.Write(").Write(automaticallyEncode ? "H(" : "").WriteCode(chunk.Code).Write(automaticallyEncode ? ")" : "").WriteLine(");"); this.CodeDefault(); this._source.WriteLine("}"); if (this._nullBehaviour == NullBehaviour.Lenient) { this._source.WriteLine("catch(System.NullReferenceException)"); this.AppendOpenBrace(); if (!chunk.SilentNulls) { this._source.Write("Output.Write(\"${").Write(EscapeStringContents((string)chunk.Code)).WriteLine("}\");"); } this.AppendCloseBrace(); } else { this._source.WriteLine("catch(System.NullReferenceException ex)"); this.AppendOpenBrace(); this._source.Write("throw new System.ArgumentNullException(\"${").Write(EscapeStringContents((string)chunk.Code)).WriteLine("}\", ex);"); this.AppendCloseBrace(); } }
protected override void Visit(SendExpressionChunk chunk) { bool automaticallyEncode = chunk.AutomaticallyEncode; if (chunk.Code.ToString().StartsWith("H(")) { automaticallyEncode = false; } this._source.WriteLine("Try").AddIndent(); this.CodeIndent(chunk).Write("Output.Write(").Write(automaticallyEncode ? "H(" : "").WriteCode(chunk.Code).Write(automaticallyEncode ? ")" : "").WriteLine(")").RemoveIndent(); this.CodeDefault(); if (this._nullBehaviour == NullBehaviour.Lenient) { this._source.WriteLine("Catch ex As Global.System.NullReferenceException"); if (!chunk.SilentNulls) { this._source.AddIndent().Write("Output.Write(\"${").Write(EscapeStringContents((string)chunk.Code)).WriteLine("}\")").RemoveIndent(); } this._source.WriteLine("End Try"); } else { this._source.WriteLine("Catch ex As Global.System.NullReferenceException"); this._source.AddIndent().Write("Throw New Global.System.ArgumentNullException(\"${").Write(EscapeStringContents((string)chunk.Code)).WriteLine("}\", ex)").RemoveIndent(); this._source.WriteLine("End Try"); } }
protected override void Visit(SendExpressionChunk chunk) { if (chunk.SilentNulls) { this._source.Append("if(typeof(").Append((string)chunk.Code).Append(") != 'undefined') "); } this._source.Append("Output.Write(").Append((string)chunk.Code).AppendLine(");"); }
protected override void Visit(SendExpressionChunk chunk) { if (chunk.SilentNulls) _source.Append("if(typeof(") .Append(chunk.Code) .Append(") != 'undefined') "); _source.Append("Output.Write(").Append(chunk.Code).AppendLine(");"); }
protected override void Visit(ExpressionNode node) { SendExpressionChunk item = new SendExpressionChunk { Code = node.Code, Position = this.Locate(node), SilentNulls = node.SilentNulls, AutomaticallyEncode = node.AutomaticEncoding }; this.Chunks.Add(item); }
protected override void Visit(SendExpressionChunk chunk) { //_source.Write("output_write_adapter ").WriteLine(chunk.Code); //TODO: handle exception _source.WriteLine("begin"); _source.Indent++; _source.Write("output_write_adapter(").Write(chunk.Code).WriteLine(")"); _source.Indent--; _source.WriteLine("rescue"); if (!chunk.SilentNulls) { _source.Indent++; _source.Write("output_write_adapter \"${").Write(EscapeStringContents(chunk.Code)).WriteLine(" => \"+$!+\"}\""); _source.Indent--; } _source.WriteLine("end"); }
protected override void Visit(SendExpressionChunk chunk) { _source.WriteLine("try:"); _source.Indent++; _source.Write("OutputWriteAdapter(").Write(chunk.Code).WriteLine(")"); _source.Indent--; _source.WriteLine("except:"); _source.Indent++; if (chunk.SilentNulls) { _source.WriteLine("pass"); } else { _source.Write("OutputWriteAdapter(\"${").Write(EscapeStringContents(chunk.Code)).WriteLine("}\")"); } _source.Indent--; }
protected override void Visit(SendExpressionChunk chunk) { var automaticallyEncode = chunk.AutomaticallyEncode; if (chunk.Code.ToString().StartsWith("H(")) automaticallyEncode = false; _source.WriteLine("Try").AddIndent(); CodeIndent(chunk) .Write("Output.Write(") .Write(automaticallyEncode ? "H(" : "") .WriteCode(chunk.Code) .Write(automaticallyEncode ? ")" : "") .WriteLine(")") .RemoveIndent(); CodeDefault(); if (_nullBehaviour == NullBehaviour.Lenient) { _source.WriteLine("Catch ex As Global.System.NullReferenceException"); if (!chunk.SilentNulls) { _source .AddIndent() .Write("Output.Write(\"${") .Write(EscapeStringContents(chunk.Code)) .WriteLine("}\")") .RemoveIndent(); } _source.WriteLine("End Try"); } else { _source.WriteLine("Catch ex As Global.System.NullReferenceException"); _source .AddIndent() .Write("Throw New Global.System.ArgumentNullException(\"${") .Write(EscapeStringContents(chunk.Code)) .WriteLine("}\", ex)") .RemoveIndent(); _source.WriteLine("End Try"); } }
protected override void Visit(SendExpressionChunk chunk) { var automaticallyEncode = chunk.AutomaticallyEncode; if (chunk.Code.ToString().StartsWith("H(")) automaticallyEncode = false; _source .WriteLine("try") .WriteLine("{"); CodeIndent(chunk) .Write("Output.Write(") .Write(automaticallyEncode ? "H(" : "") .WriteCode(chunk.Code) .Write(automaticallyEncode ? ")" : "") .WriteLine(");"); CodeDefault(); _source .WriteLine("}"); if (_nullBehaviour == NullBehaviour.Lenient) { _source.WriteLine("catch(System.NullReferenceException)"); AppendOpenBrace(); if (!chunk.SilentNulls) { _source.Write("Output.Write(\"${") .Write(EscapeStringContents(chunk.Code)) .WriteLine("}\");"); } AppendCloseBrace(); } else { _source.WriteLine("catch(System.NullReferenceException ex)"); AppendOpenBrace(); _source.Write("throw new System.ArgumentNullException(\"${") .Write(EscapeStringContents(chunk.Code)) .WriteLine("}\", ex);"); AppendCloseBrace(); } }
protected abstract void Visit(SendExpressionChunk chunk);
protected override void Visit(SendExpressionChunk chunk) { Examine(chunk.Code); }
protected override void Visit(SendExpressionChunk chunk) { }
protected override void Visit(SendExpressionChunk chunk) { chunk.Code = this.Process(chunk, chunk.Code); base.Visit(chunk); }
protected override void Visit(SendExpressionChunk chunk) { chunk.Code = Process(chunk, chunk.Code); base.Visit(chunk); }
protected override void Visit(SendExpressionChunk chunk) { _source.Append("Output.Write(").Append(chunk.Code).AppendLine(");"); }