protected override void Visit(ResolveUrlChunk chunk) { if (!Context.Host.DesignTimeMode && String.IsNullOrEmpty(chunk.Url)) { return; } // TODO: Add instrumentation if (!String.IsNullOrEmpty(chunk.Url) && !Context.Host.DesignTimeMode) { if (Context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput) { if (!String.IsNullOrEmpty(Context.TargetWriterName)) { Writer.WriteStartMethodInvocation(Context.Host.GeneratedClassContext.WriteLiteralToMethodName) .Write(Context.TargetWriterName) .WriteParameterSeparator(); } else { Writer.WriteStartMethodInvocation(Context.Host.GeneratedClassContext.WriteLiteralMethodName); } } Writer.WriteStartMethodInvocation(Context.Host.GeneratedClassContext.ResolveUrlMethodName) .WriteStringLiteral(chunk.Url) .WriteEndMethodInvocation(endLine: false); if (Context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput) { Writer.WriteEndMethodInvocation(); } } }
protected override void Visit(ResolveUrlChunk chunk) { if (!Context.Host.DesignTimeMode && string.IsNullOrEmpty(chunk.Url)) { return; } var generateInstrumentation = ShouldGenerateInstrumentationForExpressions(); if (generateInstrumentation) { // Add a non-literal context call (non-literal because the expanded URL will not match the source // character-by-character) Writer.WriteStartInstrumentationContext(Context, chunk.Association, isLiteral: false); } if (!string.IsNullOrEmpty(chunk.Url) && !Context.Host.DesignTimeMode) { if (Context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput) { RenderPreWriteStart(); } Writer.WriteStartMethodInvocation(Context.Host.GeneratedClassContext.ResolveUrlMethodName) .WriteStringLiteral(chunk.Url) .WriteEndMethodInvocation(endLine: false); if (Context.ExpressionRenderingMode == ExpressionRenderingMode.WriteToOutput) { Writer.WriteEndMethodInvocation(); } } if (generateInstrumentation) { Writer.WriteEndInstrumentationContext(Context); } }
protected override void Visit(ResolveUrlChunk chunk) { }
/// <summary> /// Writes code for the given <paramref name="chunk"/>. /// </summary> /// <param name="chunk">The <see cref="ResolveUrlChunk"/> to render.</param> /// <remarks> /// Allowed to support future C# extensions. Likely "~/..." will lead to a C# compilation error but that is up /// to the compiler. /// </remarks> protected override void Visit(ResolveUrlChunk chunk) { RenderCode(chunk.Url, (Span)chunk.Association); }
protected abstract void Visit(ResolveUrlChunk chunk);