本文整理汇总了C#中Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput.SuppressOutput方法的典型用法代码示例。如果您正苦于以下问题:C# TagHelperOutput.SuppressOutput方法的具体用法?C# TagHelperOutput.SuppressOutput怎么用?C# TagHelperOutput.SuppressOutput使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput
的用法示例。
在下文中一共展示了TagHelperOutput.SuppressOutput方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessAsync
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
var childContent = await output.GetChildContentAsync();
var modalContext = (ModalContext)context.Items[typeof(ModalTagHelper)];
modalContext.Body = childContent;
output.SuppressOutput();
}
示例2: Process
public override void Process(TagHelperContext context, TagHelperOutput output)
{
if (!Condition)
{
output.SuppressOutput();
}
}
示例3: ProcessAsync
/// <inheritdoc />
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (output == null)
{
throw new ArgumentNullException(nameof(output));
}
IHtmlContent content = null;
// Create a cancellation token that will be used
// to release the task from the memory cache.
var tokenSource = new CancellationTokenSource();
if (Enabled)
{
var cacheKey = new CacheTagKey(this);
content = await _distributedCacheService.ProcessContentAsync(output, cacheKey, GetDistributedCacheEntryOptions());
}
else
{
content = await output.GetChildContentAsync();
}
// Clear the contents of the "cache" element since we don't want to render it.
output.SuppressOutput();
output.Content.SetHtmlContent(content);
}
示例4: Process
public override void Process(TagHelperContext context, TagHelperOutput output)
{
if (ShowIfNull != null)
{
output.SuppressOutput();
}
}
示例5: Process
public override void Process(TagHelperContext context, TagHelperOutput output)
{
// If a condition is set and evaluates to false, don't render the tag.
if (Condition.HasValue && !Condition.Value)
{
output.SuppressOutput();
}
}
示例6: ProcessAsync
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
var content = await output.GetChildContentAsync();
var collectionContext = (InputCollectionContext)context.Items[typeof(InputCollectionTagHelper)];
var localContext = new InputCollectionItemContext() { Label = Label, Content = content };
collectionContext.Items.Add(localContext);
output.SuppressOutput();
}
示例7: Process
public override void Process(TagHelperContext context, TagHelperOutput output)
{
output.TagName = null;
if (Authorization == null) return;
Int32? accountId = ViewContext.HttpContext.User.Id();
String area = Area ?? ViewContext.RouteData.Values["area"] as String;
String action = Action ?? ViewContext.RouteData.Values["action"] as String;
String controller = Controller ?? ViewContext.RouteData.Values["controller"] as String;
if (!Authorization.IsAuthorizedFor(accountId, area, controller, action))
output.SuppressOutput();
}
示例8: Process
public override async void Process(TagHelperContext context, TagHelperOutput output)
{
if (!context.Items.ContainsKey(typeof(MiniWebMenuContext)))
{
throw new InvalidOperationException($"Can only be used inside a tag with the {MiniWebMenuTagHelper.MiniWebMenuAttributename} attribute set");
}
else
{
var modalContext = (MiniWebMenuContext)context.Items[typeof(MiniWebMenuContext)];
modalContext.ItemTemplate = await output.GetChildContentAsync();
output.SuppressOutput();
}
}
示例9: ProcessAsync
public async override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
if (String.IsNullOrEmpty(Name))
{
throw new ArgumentException("The name attribute can't be empty");
}
var childContent = await output.GetChildContentAsync();
var zone = _layoutAccessor.GetLayout().Zones[Name];
zone.Add(childContent, Position);
// Don't render the zone tag or the inner content
output.SuppressOutput();
}
示例10: ProcessAsync
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
if (ShowDismiss)
{
output.PreContent.AppendFormat(@"<button type='button' class='btn btn-default' data-dismiss='modal'>{0}</button>", DismissText);
}
var childContent = await output.GetChildContentAsync();
var footerContent = new DefaultTagHelperContent();
if (ShowDismiss)
{
footerContent.AppendFormat(@"<button type='button' class='btn btn-default' data-dismiss='modal'>{0}</button>", DismissText);
}
footerContent.AppendHtml(childContent);
var modalContext = (ModalContext)context.Items[typeof(ModalTagHelper)];
modalContext.Footer = footerContent;
output.SuppressOutput();
}
示例11: Process
public override async void Process(TagHelperContext context, TagHelperOutput output)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (output == null)
{
throw new ArgumentNullException(nameof(output));
}
(_htmlHelper as IViewContextAware)?.Contextualize(ViewContext);
await _htmlHelper.RenderPartialAsync("~/Views/Shared/_Editor.cshtml", _bricsContextAccessor.CurrentPage);
output.SuppressOutput();
}
示例12: Process
public override void Process(TagHelperContext context, TagHelperOutput output)
{
if (_webSite.IsAuthenticated(ViewContext.HttpContext.User))
{
output.TagMode = TagMode.StartTagAndEndTag;
//add the own contents.
output.Content.AppendHtml(output.GetChildContentAsync().Result);
(_htmlHelper as IViewContextAware )?.Contextualize(ViewContext);
//admin content
var content = _htmlHelper.Partial(_webSite.Configuration.EmbeddedResourcePath + MiniWebFileProvider.ADMIN_FILENAME);
output.PreContent.AppendHtml(content);
if (!IgnoreAdminStart)
{
output.Content.AppendHtml($"<script>$(function(){{$('{MiniWebAdminTag}').miniwebAdmin();}});</script>");
}
}
else
{
output.SuppressOutput();
}
}
示例13: ProcessAsync
/// <inheritdoc />
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
if (context == null)
{
throw new ArgumentNullException(nameof(context));
}
if (output == null)
{
throw new ArgumentNullException(nameof(output));
}
IHtmlContent content = null;
if (Enabled)
{
var cacheKey = new CacheTagKey(this, context);
MemoryCacheEntryOptions options;
while (content == null)
{
Task<IHtmlContent> result = null;
if (!MemoryCache.TryGetValue(cacheKey, out result))
{
var tokenSource = new CancellationTokenSource();
// Create an entry link scope and flow it so that any tokens related to the cache entries
// created within this scope get copied to this scope.
options = GetMemoryCacheEntryOptions();
options.AddExpirationToken(new CancellationChangeToken(tokenSource.Token));
var tcs = new TaskCompletionSource<IHtmlContent>();
// The returned value is ignored, we only do this so that
// the compiler doesn't complain about the returned task
// not being awaited
var localTcs = MemoryCache.Set(cacheKey, tcs.Task, options);
try
{
// The entry is set instead of assigning a value to the
// task so that the expiration options are are not impacted
// by the time it took to compute it.
using (var entry = MemoryCache.CreateEntry(cacheKey))
{
// The result is processed inside an entry
// such that the tokens are inherited.
result = ProcessContentAsync(output);
content = await result;
entry.SetOptions(options);
entry.Value = result;
}
}
catch
{
// Remove the worker task from the cache in case it can't complete.
tokenSource.Cancel();
throw;
}
finally
{
// If an exception occurs, ensure the other awaiters
// render the output by themselves.
tcs.SetResult(null);
}
}
else
{
// There is either some value already cached (as a Task)
// or a worker processing the output. In the case of a worker,
// the result will be null, and the request will try to acquire
// the result from memory another time.
content = await result;
}
}
}
else
{
content = await output.GetChildContentAsync();
}
// Clear the contents of the "cache" element since we don't want to render it.
output.SuppressOutput();
output.Content.SetHtmlContent(content);
}
示例14: Process
/// <summary>
/// Synchronously executes the <see cref="TagHelper" /> with the given <paramref name="context" /> and
/// <paramref name="output" />.
/// </summary>
/// <param name="context">Contains information associated with the current HTML tag.</param>
/// <param name="output">A stateful HTML element used to generate an HTML tag.</param>
public override void Process(TagHelperContext context, TagHelperOutput output)
{
// State check
if (output.TagMode != TagMode.SelfClosing)
{
throw new InvalidOperationException($"The '{HtmlTagName}' tag must use self closing mode.");
}
// Get information and build up context
var generator = GetRealGenerator(context);
var options = GetRealOptions(context);
CheckOptions(options);
int currentPage, totalPage;
GetPagingInfo(context, out currentPage, out totalPage);
var pagerContext = new PagerGenerationContext(currentPage, totalPage, options, ViewContext, GenerationMode);
// Generate result
var result = generator.GeneratePager(pagerContext);
// Disable default element output
output.SuppressOutput();
// Append pager content
output.PostElement.AppendHtml(result);
}
示例15: Process
public override void Process(TagHelperContext context, TagHelperOutput output)
{
output.SuppressOutput();
if (String.IsNullOrEmpty(Name) && !String.IsNullOrEmpty(Src))
{
// Include custom script url
var setting = _resourceManager.Include("script", Src, DebugSrc);
if (At != ResourceLocation.Unspecified)
{
setting.AtLocation(At);
}
if (!String.IsNullOrEmpty(Condition))
{
setting.UseCondition(Condition);
}
setting.UseDebugMode(Debug);
if (!String.IsNullOrEmpty(Culture))
{
setting.UseCulture(Culture);
}
foreach (var attribute in output.Attributes)
{
setting.SetAttribute(attribute.Name, attribute.Value.ToString());
}
}
else if (!String.IsNullOrEmpty(Name) && String.IsNullOrEmpty(Src))
{
// Resource required
var setting = _resourceManager.RegisterResource("script", Name);
if (At != ResourceLocation.Unspecified)
{
setting.AtLocation(At);
}
setting.UseCdn(UseCdn);
if (!String.IsNullOrEmpty(Condition))
{
setting.UseCondition(Condition);
}
setting.UseDebugMode(Debug);
if (!String.IsNullOrEmpty(Culture))
{
setting.UseCulture(Culture);
}
if (!String.IsNullOrEmpty(Version))
{
setting.UseVersion(Version);
}
}
else if (!String.IsNullOrEmpty(Name) && !String.IsNullOrEmpty(Src))
{
// Inline declaration
var definition = _resourceManager.InlineManifest.DefineScript(Name);
definition.SetUrl(Src, DebugSrc);
if (!String.IsNullOrEmpty(Version))
{
definition.SetVersion(Version);
}
if (!String.IsNullOrEmpty(CdnSrc))
{
definition.SetCdn(CdnSrc, DebugCdnSrc);
}
if (!String.IsNullOrEmpty(Culture))
{
definition.SetCultures(Culture.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries));
}
if (!String.IsNullOrEmpty(DependsOn))
{
definition.SetDependencies(DependsOn.Split(new[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries));
}
if (!String.IsNullOrEmpty(Version))
{
definition.SetVersion(Version);
}
}
else if (String.IsNullOrEmpty(Name) && String.IsNullOrEmpty(Src))
{
// Custom script content
var childContent = output.GetChildContentAsync().Result;
//.........这里部分代码省略.........