當前位置: 首頁>>代碼示例>>C#>>正文


C# TagHelpers.TagHelperOutput類代碼示例

本文整理匯總了C#中Microsoft.AspNet.Razor.Runtime.TagHelpers.TagHelperOutput的典型用法代碼示例。如果您正苦於以下問題:C# TagHelperOutput類的具體用法?C# TagHelperOutput怎麽用?C# TagHelperOutput使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TagHelperOutput類屬於Microsoft.AspNet.Razor.Runtime.TagHelpers命名空間,在下文中一共展示了TagHelperOutput類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的Microsoft.AspNet.Razor.Runtime.TagHelpers.TagHelperOutput類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。