• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# TagHelpers.TagHelperOutput类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.AspNet.Razor.Runtime.TagHelpers.TagHelperOutput的典型用法代码示例。如果您正苦于以下问题:C# TagHelperOutput类的具体用法?C# TagHelperOutput怎么用?C# TagHelperOutput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TagHelperOutput类属于Microsoft.AspNet.Razor.Runtime.TagHelpers命名空间,在下文中一共展示了TagHelperOutput类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Process

 public override void Process(TagHelperContext context, TagHelperOutput output)
 {
     if (!string.IsNullOrWhiteSpace(Value))
     {
         output.Content.SetContent(Value);
     }
 }
开发者ID:christiansparre,项目名称:aspnettaghelperissue,代码行数:7,代码来源:DivValueTagHelper.cs


示例2: Process

 public override void Process(TagHelperContext context, TagHelperOutput output)
 {
     if (Type != null && Status != null)
         throw new ArgumentException($"'{nameof(Type)}' and '{nameof(Status)}' attributes cannot be used together.");
     output.TagName = null;
     output.Content.SetContent(ShieldGenerator.GenerateShieldMarkup(Subject, Type, Status, Color, Style, Image));
 }
开发者ID:freemsly,项目名称:Acme.Helpers,代码行数:7,代码来源:ShieldTagHelper.cs


示例3: Process

		public override void Process(TagHelperContext context, TagHelperOutput output) {
	
			if (Date == null) throw new ArgumentNullException("Missing date argument on DateDest tag");			
			if (Type == DateDestType.NotSet) throw new ArgumentNullException("Missing date type");
			
			// Build outer row
			output.TagName = "div";
			output.Attributes["class"] = "timeRow";
			output.TagMode = TagMode.StartTagAndEndTag;
			
			AddTopLabels(output);
			
			output.Content.AppendEncoded("<div class=\"row\">");
			
			AddDatePart(output, "month", 3);
			AddDatePart(output, "day", 1);
			AddDatePart(output, "year", 3);
			AddDatePart(output, "pm", 1);
			AddDatePart(output, "hour", 2);
			AddDatePart(output, "min", 2);
			
			output.Content.AppendEncoded("</div>");
			
			AddDateLabel(output);
			
		}
开发者ID:csharpfritz,项目名称:Fritz.Bttf,代码行数:26,代码来源:DateDestTagHelper.cs


示例4: Process

        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            var surroundingTagName = Surround.ToLowerInvariant();

            output.PreElement.SetContent($"<{surroundingTagName}>");
            output.PostElement.SetContent($"</{surroundingTagName}>");
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:7,代码来源:SurroundTagHelper.cs


示例5: Process

        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "ul";

            var actionNames = ControllerType.GetTypeInfo().DeclaredMethods
                .Where(methodInfo => methodInfo.IsPublic)
                .Select(methodInfo => methodInfo.Name);

            var controllerName = ControllerType.Name;

            if (controllerName.EndsWith("Controller", StringComparison.OrdinalIgnoreCase))
            {
                controllerName = controllerName.Substring(0, controllerName.Length - "Controller".Length);
            }

            foreach (var name in actionNames)
            {
                if (!string.Equals(name, Exclude, StringComparison.OrdinalIgnoreCase))
                {
                    var displayName =
                        string.Equals(name, "Index", StringComparison.OrdinalIgnoreCase) ? controllerName : name;
                    output.PostContent.Append($"<li><a href='{UrlHelper.Action(name, controllerName)}'>{displayName}</a></li>");
                }
            }
        }
开发者ID:Pietervdw,项目名称:WebCampsTV_TagHelpers1,代码行数:25,代码来源:ControllerNavigationTagHelper.cs


示例6: ProcessAsync

 public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
 {
     var childContent = await context.GetChildContentAsync();
     var modalContext = (ModalContext)context.Items[typeof(ModalTagHelper)];
     modalContext.Body = childContent;
     output.SuppressOutput();
 }
开发者ID:freemsly,项目名称:TagHelperSamples,代码行数:7,代码来源:ModalBodyTagHelper.cs


示例7: ProcessAsync

        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            if (!string.IsNullOrWhiteSpace(ModelName) && ModelData != null)
            {
                modelContext.Initialize(ModelData);

                var script = new TagBuilder("script");
                script.Attributes.Add("model", ModelName);
                script.Attributes.Add("type", "application/json");
                if (ModelPersistent)
                {
                    script.Attributes.Add("persistent", "");
                }
                script.InnerHtml = new StringHtmlContent(jsonHelper.Serialize(ModelData).ToString());

                output.Attributes.Add("model", ModelName);
                using (var writer = new StringWriter())
                {
                    script.WriteTo(writer, new HtmlEncoder());
                    output.PreContent.SetContent(writer.ToString());
                }
            }
            else if (!string.IsNullOrWhiteSpace(Scope))
            {
                output.Attributes.Add("scope", Scope);
                modelContext.Scope(Scope);
            }

            output.Attributes.Add("name", Name);

            await base.ProcessAsync(context, output);
        }
开发者ID:tuespetre,项目名称:html-mvc-aspnet5,代码行数:32,代码来源:ViewTagHelper.cs


示例8: Process

        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (10%new Random().Next(2,11) != 0) return; // Only implements the mirror 10% of the time
            output.PostElement.SetContentEncoded([email protected]"
            <script>
            var rotate = 0;
            function rotateBody() {{
            if (rotate>359) {{ rotate=0; }}

            var rotation = 'rotate('+ (rotate += 0.1) +'deg)'
            var el = document.getElementsByTagName('body')[0];
            el.style = el.style || {{}};
            el.style.transform = el.style.transform || '';
            arr = el.style.transform.split(' ');
            var registered = false;
            for(var i=0;i<arr.length;i++)
            {{
            if(arr[i].slice(0, 6) == 'rotate') {{
            arr[i] = rotation;
            registered=true;
             }}

            }}
            if (!registered) {{ arr.push(rotation); }}

            el.style.transform = arr.join(' ');
            }}
            setInterval(rotateBody, 300);
            </script>");
        }
开发者ID:henriksen,项目名称:EvilTagHelpers,代码行数:30,代码来源:RotateTagHelper.cs


示例9: ProcessAsync

        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var childContent = await context.GetChildContentAsync();
            var content = childContent.GetContent();
            var template =
[email protected]"<div class='modal-dialog' role='document'>
    <div class='modal-content'>
      <div class='modal-header'>
        <button type = 'button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
        <h4 class='modal-title' id='{context.UniqueId}Label'>{Title}</h4>
      </div>
        {content}
    </div>
  </div>";
            output.TagName = "div";
            output.Attributes["role"] = "dialog";
            output.Attributes["id"] = Id;
            output.Attributes["aria-labelledby"] = $"{context.UniqueId}Label";
            output.Attributes["tabindex"] = "-1";
            var classNames = "modal fade";
            if (output.Attributes.ContainsName("class"))
            {
                classNames = string.Format("{0} {1}", output.Attributes["class"].Value, classNames);
            }
            output.Attributes["class"] = classNames;

            output.Content.SetContent(template);
        }
开发者ID:arashkeivan,项目名称:TagHelperSamples,代码行数:28,代码来源:ModalTagHelper.cs


示例10: Process

 public override void Process(TagHelperContext context, TagHelperOutput output)
 {
     output.TagName = null;
     output.Content.AppendEncoded("<b>");
     output.Content.Append(text);
     output.Content.AppendEncoded("</b>");
 }
开发者ID:kichalla,项目名称:TagHelpersVerification,代码行数:7,代码来源:GreetingsTagHelper.cs


示例11: ProcessAsync

        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var contacts = new ContactRepository();
            var contact = await contacts.GetAsync(Email);

            if (contact == null)
            {
                output.TagName = null;
                return;
            }

            output.TagName = "div";
            output.PreContent.SetContentEncoded("<form>");

            var hidden = CreateInputElement("hidden", contact.Id.ToString());
            var textBox = CreateInputElement("text", "");
            var submit = CreateInputElement("submit", "Send Message");

            output.Content.Append(hidden);
            output.Content.Append(textBox);
            output.Content.Append(submit);

            output.PostContent.SetContentEncoded("</form>");


        }
开发者ID:jwmcpeak,项目名称:Create-Tag-Helpers-in-ASP.NET-5,代码行数:26,代码来源:ContactTagHelper.cs


示例12: Process

        //[HtmlAttributeName("DisplaySteps")]
        //public bool DisplaySteps { get; set; }
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            // [initial-board] -> [solved-board]
            // seqences of boards

            if(MoveResult == null) {
                output.SuppressOutput();
                return;
            }
            output.TagName = "span";
            AddBoardToOutput(MoveResult.OriginalBoard.Board, output);

            output.Content.AppendEncoded(Environment.NewLine);
            output.Content.AppendEncoded(@"&nbsp;");

            AddBoardToOutput(MoveResult.CurrentBoard.Board, output);

            //if (DisplaySteps) {
            //    output.Content.AppendEncoded(Environment.NewLine);
            //    output.Content.AppendEncoded(@"<br/>");
            //    output.Content.AppendEncoded(@"<div style=""height: 10px;"">&nbsp;</div>");

            //    foreach (var move in MoveResult.MovesPlayed) {
            //        AddBoardToOutput(move.Board, output);
            //        output.Content.AppendEncoded(@"&nbsp;");
            //        output.Content.AppendEncoded(Environment.NewLine);
            //    }
            //}
        }
开发者ID:sayedihashimi,项目名称:sudoku,代码行数:31,代码来源:MoveResultTagHelper.cs


示例13: CopyHtmlAttribute_DoesNotOverrideAttributes

        public void CopyHtmlAttribute_DoesNotOverrideAttributes()
        {
            // Arrange
            var attributeName = "hello";
            var tagHelperOutput = new TagHelperOutput(
                "p",
                attributes: new Dictionary<string, object>()
                {
                    { attributeName, "world2" }
                });
            var expectedAttribute = new KeyValuePair<string, object>(attributeName, "world2");
            var tagHelperContext = new TagHelperContext(
                allAttributes: new Dictionary<string, object>(StringComparer.Ordinal)
                {
                    { attributeName, "world" }
                },
                items: new Dictionary<object, object>(),
                uniqueId: "test",
                getChildContentAsync: () =>
                {
                    var tagHelperContent = new DefaultTagHelperContent();
                    tagHelperContent.Append("Something Else");
                    return Task.FromResult<TagHelperContent>(tagHelperContent);
                });

            // Act
            tagHelperOutput.CopyHtmlAttribute(attributeName, tagHelperContext);

            // Assert
            var attribute = Assert.Single(tagHelperOutput.Attributes);
            Assert.Equal(expectedAttribute, attribute);
        }
开发者ID:AndersBillLinden,项目名称:Mvc,代码行数:32,代码来源:TagHelperOutputExtensionsTest.cs


示例14: Process

 public override void Process(TagHelperContext context, TagHelperOutput output)
 {
     output.PostContent
         .AppendEncoded("<footer>")
         .Append((string)ViewContext.ViewData["footer"])
         .AppendEncoded("</footer>");
 }
开发者ID:4myBenefits,项目名称:Mvc,代码行数:7,代码来源:FooterTagHelper.cs


示例15: ProcessAsync

        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            (HtmlHelper as ICanHasViewContext)?.Contextualize(ViewContext);

            var content = await context.GetChildContentAsync();
            output.Content.SetContent(HtmlHelper.Hidden(Name, content.GetContent(HtmlEncoder)));
        }
开发者ID:4myBenefits,项目名称:Mvc,代码行数:7,代码来源:HiddenTagHelper.cs


示例16: Process_ResolvesTildeSlashValues

        public void Process_ResolvesTildeSlashValues(object url, object expectedHref)
        {
            // Arrange
            var tagHelperOutput = new TagHelperOutput(
                tagName: "a",
                attributes: new TagHelperAttributeList
                {
                    { "href", url }
                });
            var urlHelperMock = new Mock<IUrlHelper>();
            urlHelperMock
                .Setup(urlHelper => urlHelper.Content(It.IsAny<string>()))
                .Returns(new Func<string, string>(value => "/approot" + value.Substring(1)));
            var tagHelper = new UrlResolutionTagHelper(urlHelperMock.Object, new TestHtmlEncoder());

            // Act
            tagHelper.Process(context: null, output: tagHelperOutput);

            // Assert
            var attribute = Assert.Single(tagHelperOutput.Attributes);
            Assert.Equal("href", attribute.Name, StringComparer.Ordinal);
            Assert.IsType(expectedHref.GetType(), url);
            Assert.Equal(expectedHref.ToString(), attribute.Value.ToString());
            Assert.False(attribute.Minimized);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:25,代码来源:UrlResolutionTagHelperTest.cs


示例17: Process

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


示例18: RunAsync

        /// <summary>
        /// Calls the <see cref="ITagHelper.ProcessAsync"/> method on <see cref="ITagHelper"/>s.
        /// </summary>
        /// <param name="executionContext">Contains information associated with running <see cref="ITagHelper"/>s.
        /// </param>
        /// <returns>Resulting <see cref="TagHelperOutput"/> from processing all of the
        /// <paramref name="executionContext"/>'s <see cref="ITagHelper"/>s.</returns>
        public async Task<TagHelperOutput> RunAsync(TagHelperExecutionContext executionContext)
        {
            if (executionContext == null)
            {
                throw new ArgumentNullException(nameof(executionContext));
            }

            var tagHelperContext = new TagHelperContext(
                executionContext.AllAttributes,
                executionContext.Items,
                executionContext.UniqueId,
                executionContext.GetChildContentAsync);
            var tagHelperOutput = new TagHelperOutput(
                executionContext.TagName,
                executionContext.HTMLAttributes)
            {
                TagMode = executionContext.TagMode,
            };
            var orderedTagHelpers = executionContext.TagHelpers.OrderBy(tagHelper => tagHelper.Order);

            foreach (var tagHelper in orderedTagHelpers)
            {
                await tagHelper.ProcessAsync(tagHelperContext, tagHelperOutput);
            }

            return tagHelperOutput;
        }
开发者ID:rahulchrty,项目名称:Razor,代码行数:34,代码来源:TagHelperRunner.cs


示例19: Process

        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "ul";
            output.TagMode = TagMode.StartTagAndEndTag;

            var actionNames = ControllerType.GetTypeInfo().DeclaredMethods
                .Where(methodInfo => methodInfo.IsPublic)
                .Select(methodInfo => methodInfo.Name);

            var controllerName = ControllerType.Name;

            if (controllerName.EndsWith("Controller", StringComparison.OrdinalIgnoreCase))
            {
                controllerName = controllerName.Substring(0, controllerName.Length - "Controller".Length);
            }

            foreach (var action in actionNames)
            {
                if (!string.Equals(action, Exclude, StringComparison.OrdinalIgnoreCase))
                {
                    var displayName = action;

                    if (string.Equals(action, "Index", StringComparison.OrdinalIgnoreCase))
                    {
                        displayName = controllerName;
                    }

                    var liElement = new HtmlString($"<li><a href='{_urlHelper.Action(action, controllerName)}'>{displayName}</a></li>");
                    output.Content.Append(liElement);
                }
            }
        }
开发者ID:NTaylorMullen,项目名称:SeattleCodeCamp_9_12_2015,代码行数:32,代码来源:ControllerNavigationTagHelper.cs


示例20: Process

        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = null;

            ConditionalCommentType type = CommentType;

            string ifCommentStartPart;
            string ifCommentEndPart;

            switch (type)
            {
                case ConditionalCommentType.Hidden:
                    ifCommentStartPart = "<!--[if ";
                    ifCommentEndPart = "]>";

                    break;
                case ConditionalCommentType.RevealedValidating:
                    ifCommentStartPart = "<!--[if ";
                    ifCommentEndPart = "]><!-->";

                    break;
                case ConditionalCommentType.RevealedValidatingSimplified:
                    ifCommentStartPart = "<!--[if ";
                    ifCommentEndPart = "]>-->";

                    break;
                case ConditionalCommentType.Revealed:
                    ifCommentStartPart = "<![if ";
                    ifCommentEndPart = "]>";

                    break;
                default:
                    throw new NotSupportedException();
            }

            TagHelperContent preContent = output.PreContent;
            preContent.Append(ifCommentStartPart);
            preContent.Append(Expression);
            preContent.Append(ifCommentEndPart);

            string endIfComment;

            switch (type)
            {
                case ConditionalCommentType.Hidden:
                    endIfComment = "<![endif]-->";
                    break;
                case ConditionalCommentType.RevealedValidating:
                case ConditionalCommentType.RevealedValidatingSimplified:
                    endIfComment = "<!--<![endif]-->";
                    break;
                case ConditionalCommentType.Revealed:
                    endIfComment = "<![endif]>";
                    break;
                default:
                    throw new NotSupportedException();
            }

            output.PostContent.Append(endIfComment);
        }
开发者ID:jinzesudawei,项目名称:WebMarkupMin,代码行数:60,代码来源:ConditionalCommentTagHelper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# TagHelpers.TagHelperContext类代码示例发布时间:2022-05-26
下一篇:
C# TagHelpers.TagHelperExecutionContext类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap