public override void WriteUsingDirective(CodeRenderingContext context, UsingDirectiveIntermediateNode node) { if (node.Source.HasValue) { using (context.CodeWriter.BuildLinePragma(node.Source.Value, context)) { context.AddSourceMappingFor(node); context.CodeWriter.WriteUsing(node.Content); } } else { context.CodeWriter.WriteUsing(node.Content); } }
public override void WriteCSharpExpression(CodeRenderingContext context, CSharpExpressionIntermediateNode node) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (node == null) { throw new ArgumentNullException(nameof(node)); } if (node.Children.Count == 0) { return; } if (node.Source != null) { using (context.CodeWriter.BuildLinePragma(node.Source.Value, context)) { var offset = DesignTimeDirectivePass.DesignTimeVariable.Length + " = ".Length; context.CodeWriter.WritePadding(offset, node.Source, context); context.CodeWriter.WriteStartAssignment(DesignTimeDirectivePass.DesignTimeVariable); for (var i = 0; i < node.Children.Count; i++) { if (node.Children[i] is IntermediateToken token && token.IsCSharp) { context.AddSourceMappingFor(token); context.CodeWriter.Write(token.Content); } else { // There may be something else inside the expression like a Template or another extension node. context.RenderNode(node.Children[i]); } }