/// <summary> /// Ends the current writing scope that was started by calling <see cref="StartTagHelperWritingScope"/>. /// </summary> /// <returns>The buffered <see cref="TagHelperContent"/>.</returns> public TagHelperContent EndTagHelperWritingScope() { if (TagHelperScopes.Count == 0) { throw new InvalidOperationException("There is no active scope to write"); } var scopeInfo = TagHelperScopes.Pop(); // Get the content written during the current scope. var tagHelperContent = new DefaultTagHelperContent(); tagHelperContent.AppendHtml(scopeInfo.Buffer); // Restore previous scope. HtmlEncoder = scopeInfo.HtmlEncoder; PageContext.Writer = scopeInfo.Writer; return(tagHelperContent); }
/// <summary> /// Ends the current writing scope that was started by calling <see cref="StartTagHelperWritingScope"/>. /// </summary> /// <returns>The buffered <see cref="TagHelperContent"/>.</returns> public TagHelperContent EndTagHelperWritingScope() { if (TagHelperScopes.Count == 0) { throw new InvalidOperationException(Resources.RazorPage_ThereIsNoActiveWritingScopeToEnd); } var scopeInfo = TagHelperScopes.Pop(); // Get the content written during the current scope. var tagHelperContent = new DefaultTagHelperContent(); tagHelperContent.AppendHtml(scopeInfo.Buffer); // Restore previous scope. HtmlEncoder = scopeInfo.HtmlEncoder; ViewContext.Writer = scopeInfo.Writer; return(tagHelperContent); }