public void AppendNewLine() { var writeInvoke = CodeDomFluentBuilder .GetCodeMethodInvokeExpression("WriteLine", TextWriterVariableName) .WithInvokePrimitiveParameter(""); RenderMethod.AddExpressionStatement(writeInvoke); }
public void AppendCodeToString(string code) { var writeInvoke = CodeDomFluentBuilder .GetCodeMethodInvokeExpression("Write", TextWriterVariableName) .WithInvokeCodeSnippetToStringParameter(code); RenderMethod.AddExpressionStatement(writeInvoke); }
public void AppendSelfClosingTagSuffix() { var renderValueOrKeyAsString = CodeDomFluentBuilder .GetCodeMethodInvokeExpression("base.AppendSelfClosingTagSuffix"); var writeInvoke = CodeDomFluentBuilder .GetCodeMethodInvokeExpression("Write", TextWriterVariableName) .WithInvokeCodeParameter(renderValueOrKeyAsString); RenderMethod.AddExpressionStatement(writeInvoke); }
public void AppendVariable(string variableName) { var renderValueOrKeyAsString = CodeDomFluentBuilder .GetCodeMethodInvokeExpression("RenderValueOrKeyAsString") .WithInvokePrimitiveParameter(variableName); var writeInvoke = CodeDomFluentBuilder .GetCodeMethodInvokeExpression("Write", TextWriterVariableName) .WithInvokeCodeParameter(renderValueOrKeyAsString); RenderMethod.AddExpressionStatement(writeInvoke); }
public void AppendDocType(string docTypeId) { var docType = CodeDomFluentBuilder .GetCodeMethodInvokeExpression("GetDocType") .WithInvokePrimitiveParameter(docTypeId); var writeInvoke = CodeDomFluentBuilder .GetCodeMethodInvokeExpression("Write", TextWriterVariableName) .WithInvokeCodeParameter(docType); RenderMethod.AddExpressionStatement(writeInvoke); }
private void AppenAttributeWithValue(string name, IEnumerable <HamlNode> valueFragments, char quoteToUse) { string variableName = "value_" + RenderMethod.Statements.Count; RenderMethod.AddStatement( CodeDomFluentBuilder.GetDeclaration(typeof(StringBuilder), variableName, new CodeObjectCreateExpression("System.Text.StringBuilder", new CodeExpression[] {}))); foreach (var fragment in valueFragments) { CodeExpression parameter; if (fragment is HamlNodeTextVariable) { string nodeVariableName = ((HamlNodeTextVariable)fragment).VariableName; if (nodeVariableName.All(ch => Char.IsLetterOrDigit(ch))) { parameter = CodeDomFluentBuilder.GetCodeMethodInvokeExpression( "base.RenderValueOrKeyAsString") .WithInvokePrimitiveParameter(nodeVariableName); } else { parameter = CodeDomFluentBuilder.GetCodeMethodInvokeExpression("ToString", "Convert") .WithCodeSnippetParameter(nodeVariableName); } } else { parameter = new CodePrimitiveExpression { Value = fragment.Content }; } RenderMethod.AddExpressionStatement( CodeDomFluentBuilder.GetCodeMethodInvokeExpression("Append", variableName) .WithParameter(parameter)); } var outputExpression = CodeDomFluentBuilder .GetCodeMethodInvokeExpression("base.RenderAttributeNameValuePair") .WithInvokePrimitiveParameter(name) .WithParameter(CodeDomFluentBuilder.GetCodeMethodInvokeExpression("ToString", variableName)) .WithInvokePrimitiveParameter(quoteToUse); RenderMethod.AddExpressionStatement( CodeDomFluentBuilder.GetCodeMethodInvokeExpression("Write", TextWriterVariableName) .WithParameter(outputExpression)); }
private void AppendAttributeWithoutValue(string name) { RenderMethod.AddExpressionStatement( CodeDomFluentBuilder.GetCodeMethodInvokeExpression("Write", TextWriterVariableName) .WithInvokePrimitiveParameter(" " + name)); }