当前位置: 首页>>代码示例>>C#>>正文


C# TagHelperOutput.SuppressOutput方法代码示例

本文整理汇总了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();
 }
开发者ID:dpaquette,项目名称:TagHelperSamples,代码行数:7,代码来源:ModalBodyTagHelper.cs

示例2: Process

 public override void Process(TagHelperContext context, TagHelperOutput output)
 {
     if (!Condition)
     {
         output.SuppressOutput();
     }
 }
开发者ID:ColinDabritz,项目名称:Docs,代码行数:7,代码来源:ConditionTagHelper.cs

示例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);
        }
开发者ID:cemalshukriev,项目名称:Mvc,代码行数:35,代码来源:DistributedCacheTagHelper.cs

示例4: Process

 public override void Process(TagHelperContext context, TagHelperOutput output)
 {
     if (ShowIfNull != null)
     {
         output.SuppressOutput();
     }
 }
开发者ID:wondertrap,项目名称:AspNet5IdentityServerAngularImplicitFlow,代码行数:7,代码来源:HideShowTagHelpers.cs

示例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();
     }
 }
开发者ID:ymd1223,项目名称:Mvc,代码行数:8,代码来源:ConditionTagHelper.cs

示例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();
        }
开发者ID:iKadmium,项目名称:kadmium-osc-dmx-dotnet,代码行数:10,代码来源:InputCollectionItemTagHelper.cs

示例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();
        }
开发者ID:NonFactors,项目名称:MVC6.Template,代码行数:13,代码来源:AuthorizeTagHelper.cs

示例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();
			}
		}
开发者ID:IRooc,项目名称:miniweb-coreclr,代码行数:13,代码来源:MiniWebMenuTagHelper.cs

示例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();
        }
开发者ID:jchenga,项目名称:Orchard2,代码行数:15,代码来源:ZoneTagHelper.cs

示例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();
 }
开发者ID:dpaquette,项目名称:TagHelperSamples,代码行数:17,代码来源:ModalFooterTagHelper.cs

示例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();
        }
开发者ID:marcuslindblom,项目名称:aspnet5,代码行数:18,代码来源:BrickPileEditorTagHelper.cs

示例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();
            }
        }
开发者ID:IRooc,项目名称:miniweb-coreclr,代码行数:24,代码来源:MiniWebAdminTagHelper.cs

示例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);
        }
开发者ID:cemalshukriev,项目名称:Mvc,代码行数:94,代码来源:CacheTagHelper.cs

示例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);
		}
开发者ID:sgjsakura,项目名称:AspNetCore,代码行数:33,代码来源:PagerTagHelper.cs

示例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;

//.........这里部分代码省略.........
开发者ID:jchenga,项目名称:Orchard2,代码行数:101,代码来源:ScriptTagHelper.cs


注:本文中的Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput.SuppressOutput方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。