コード例 #1
0
        /// <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);
        }
コード例 #2
0
ファイル: TextAreaTagHelper.cs プロジェクト: ymd1223/Mvc
        /// <inheritdoc />
        /// <remarks>Does nothing if <see cref="For"/> is <c>null</c>.</remarks>
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            var tagBuilder = Generator.GenerateTextArea(
                ViewContext,
                For.ModelExplorer,
                For.Name,
                rows: 0,
                columns: 0,
                htmlAttributes: null);

            if (tagBuilder != null)
            {
                // Overwrite current Content to ensure expression result round-trips correctly.
                output.Content.SetHtmlContent(tagBuilder.InnerHtml);

                output.MergeAttributes(tagBuilder);
            }
        }
 public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
 {
     if (DisplayProperty == null && (DisplayPropertyExplorer == null || DisplayPropertyExpressionOverride==null))
         new ArgumentNullException("display-property/display-expression-override+display-explorer");
     if (For == null && (ForPropertyExplorer == null || ForExpressionOverride == null))
         new ArgumentNullException("asp-for/for-expression-override+for-explorer");
     if (string.IsNullOrWhiteSpace(ItemsDisplayProperty)) new ArgumentNullException("items-display-property");
     if (string.IsNullOrWhiteSpace(ItemsValueProperty)) new ArgumentNullException("items-value-property");
     if (string.IsNullOrWhiteSpace(ItemsUrl)) new ArgumentNullException("items-url");
     if (string.IsNullOrWhiteSpace(UrlToken)) new ArgumentNullException("url-token");
     if (string.IsNullOrWhiteSpace(DataSetName)) new ArgumentNullException("dataset-name");
     if (MaxResults == 0) MaxResults=20;
     if (MinChars == 0) MinChars = 3;
     var currProvider = ViewContext.TagHelperProvider();
     var resolver = jsonOptions.SerializerSettings.ContractResolver as DefaultContractResolver;
     var vd = ViewContext.ViewData;
     var options = new AutocompleteOptions
     {
         Generator = generator,
         PropertyResolver = resolver != null ? resolver.GetResolvedPropertyName : new Func<string, string>(x => x),
         ForcedValueName =  currProvider.GenerateNames ? vd.GetFullHtmlFieldName(ForExpressionOverride ?? For.Name) : null,
         ForcedDisplayName = currProvider.GenerateNames ? vd.GetFullHtmlFieldName(DisplayPropertyExpressionOverride ?? DisplayProperty.Name) : null,
         NoId= !currProvider.GenerateNames || ViewContext.IsFilterRendering()
     };
     await currProvider.GetTagProcessor(TagName)(context, output, this, options, null);
 }
 public DefaultServerGridProcessor(TagHelperContext context, TagHelperOutput output, GridTagHelper tag, GridOptions options, ContextualizedHelpers helpers)
 {
     this.context = context; this.output = output; this.tag = tag;
     this.options = options; this.helpers = helpers;
     basePrefix = tag.For.Name;
     AdjustColumns();
 }
コード例 #5
0
        public override async void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "div";

            output.AppendClass("widget-box");
            output.AppendClass(Class);
            
            var originalContent = await output.GetChildContentAsync();
            var innerHtml = originalContent.GetContent();

            output.Content.Clear();

            if (!innerHtml.Contains(WidgetBoxHeaderHelper.HeaderCss))
            {
                // user is taking easy/lazy way of declaring the widget box
                output.Content.AppendHtml(WidgetBoxHeaderHelper.GetFullHeader(Title, IsCollapsible));
                var widgetBodyDiv = WidgetBoxBodyHelper.GetFullBodyInternals(Padding, innerHtml);
                output.Content.AppendHtml(widgetBodyDiv);
            }
            else
            {
                // user is doing the hardwork themselves
                output.Content.AppendHtml(innerHtml);
            }
            
            base.Process(context, output);
        }
 public override void Process(TagHelperContext context, TagHelperOutput output)
 {
     if (ShowIfNull != null)
     {
         output.SuppressOutput();
     }
 }
コード例 #7
0
ファイル: TagHelperOutputTest.cs プロジェクト: cjqian/Razor
        public async Task GetChildContentAsync_CallsGetChildContentAsync()
        {
            // Arrange
            bool? passedUseCacheResult = null;
            HtmlEncoder passedEncoder = null;
            var content = new DefaultTagHelperContent();
            var output = new TagHelperOutput(
                tagName: "tag",
                attributes: new TagHelperAttributeList(),
                getChildContentAsync: (useCachedResult, encoder) =>
                {
                    passedUseCacheResult = useCachedResult;
                    passedEncoder = encoder;
                    return Task.FromResult<TagHelperContent>(content);
                });

            // Act
            var result = await output.GetChildContentAsync();

            // Assert
            Assert.True(passedUseCacheResult.HasValue);
            Assert.True(passedUseCacheResult.Value);
            Assert.Null(passedEncoder);
            Assert.Same(content, result);
        }
コード例 #8
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "select";
            output.TagMode = TagMode.StartTagAndEndTag;

            output.AppendClass("form-control");

            var optionsList = new List<TagBuilder>();

            if (Items == null)
            {
                Items = new List<SelectListItem>();
            }

            foreach (var item in Items)
            {
                var option = new TagBuilder("option");
                option.Attributes.Add("value", item.Value);
                option.InnerHtml.Append(item.Text);

                optionsList.Add(option);
            }

            optionsList.ForEach(o =>
            {
                output.Content.AppendHtml(o);
            });

            base.Process(context, output);
        }
コード例 #9
0
 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();
 }
コード例 #10
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "div";
            output.PreContent.SetHtmlContent("<ul class=\"pagination pagination-lg\">");

            var items = new StringBuilder();
            for (var i = 1; i <= TotalPages; i++)
            {
                var li = new TagBuilder("li");

                if (i == CurrentPage)
                {
                    li.AddCssClass("active");
                }

                var a = new TagBuilder("a");
                a.MergeAttribute("href", $"{Url}?page={i}&{AdditionalParameters}");
                a.MergeAttribute("title", $"Click to go to page {i}");
                a.InnerHtml.AppendHtml(i.ToString());

                li.InnerHtml.AppendHtml(a);

                var writer = new System.IO.StringWriter();
                li.WriteTo(writer, HtmlEncoder.Default);
                var s = writer.ToString();
                items.AppendLine(s);
            }
            output.Content.SetHtmlContent(items.ToString());
            output.PostContent.SetHtmlContent("</ul>");
            output.Attributes.Clear();
            output.Attributes.Add("class", "pager");
        }
コード例 #11
0
        public override async void Process(TagHelperContext context, TagHelperOutput output)
        {
            var originalContent = await output.GetChildContentAsync();

            output.AppendClass("form-group");

            TagBuilder labelBuilder = null;
            if (!originalContent.GetContent().Contains("<label"))
            {
                labelBuilder = FormGroupLabel.Get(Horizontal, LabelText);
            }

            var contentDiv = new TagBuilder("div");

            if (Horizontal)
            {
                contentDiv.AddCssClass("col-sm-8");
            }

            contentDiv.InnerHtml.AppendHtml(originalContent.GetContent());
            
            output.TagName = "div";
            output.Content.Clear();
            if (labelBuilder != null)
            {
                output.Content.AppendHtml(labelBuilder);
            }
            output.Content.AppendHtml(contentDiv);

            base.Process(context, output);
        }
コード例 #12
0
ファイル: ImageTagHelper.cs プロジェクト: kbok/OkMidnight
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            var builder = new TagBuilder("img");
            builder.Attributes["src"] = "/pictures/" + UrlHelperThumbnailExtensions.GetThumbnail(null, Src, Size);

            output.MergeAttributes(builder);
        }
コード例 #13
0
        /// <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));
            }

            await output.GetChildContentAsync();

            var formContext = ViewContext.FormContext;
            if (formContext.HasEndOfFormContent)
            {
                // Perf: Avoid allocating enumerator
                for (var i = 0; i < formContext.EndOfFormContent.Count; i++)
                {
                    output.PostContent.AppendHtml(formContext.EndOfFormContent[i]);
                }
            }

            // Reset the FormContext
            ViewContext.FormContext = new FormContext();
        }
コード例 #14
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            //load the content items in the specified section
            if (!string.IsNullOrWhiteSpace(Section))
            {
                //Set Content edit properties on tags when logged in
                if (_webSite?.IsAuthenticated(ViewContext.HttpContext.User) == true)
                {
                    output.Attributes.Add("data-miniwebsection", Section);
                }

                //contextualize the HtmlHelper for the current ViewContext
                (_htmlHelper as IViewContextAware)?.Contextualize(ViewContext);
                //get out the current ViewPage for the Model.
                var view = ViewContext.View as RazorView;
                var viewPage = view?.RazorPage as RazorPage<ISitePage>;
                output.Content.Clear();

                if (viewPage != null)
                {
                    var sectionContent = SectionContent(_htmlHelper, viewPage.Model, Section);
                    output.Content.AppendHtml(sectionContent);
                }
            }
        }
コード例 #15
0
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var request = ViewContext.HttpContext.Request;
            var result = await Prerenderer.RenderToString(
                _applicationBasePath,
                _nodeServices,
                new JavaScriptModuleExport(ModuleName)
                {
                    ExportName = ExportName,
                    WebpackConfig = WebpackConfigPath
                },
                request.GetEncodedUrl(),
                request.Path + request.QueryString.Value,
                CustomDataParameter);
            output.Content.SetHtmlContent(result.Html);

            // Also attach any specified globals to the 'window' object. This is useful for transferring
            // general state between server and client.
            if (result.Globals != null)
            {
                var stringBuilder = new StringBuilder();
                foreach (var property in result.Globals.Properties())
                {
                    stringBuilder.AppendFormat("window.{0} = {1};",
                        property.Name,
                        property.Value.ToString(Formatting.None));
                }
                if (stringBuilder.Length > 0)
                {
                    output.PostElement.SetHtmlContent($"<script>{stringBuilder}</script>");
                }
            }
        }
コード例 #16
0
        private async Task<string> GetContent(TagHelperOutput output)
        {
            if (Content == null)
                return (await output.GetChildContentAsync()).GetContent();

            return Content.Model?.ToString();
        }
コード例 #17
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            TagBuilder table = new TagBuilder("table");
            table.GenerateId(context.UniqueId, "id");
            var attributes = context.AllAttributes.Where(a => a.Name != ItemsAttributeName).ToDictionary(a => a.Name);
            table.MergeAttributes(attributes);

            var tr = new TagBuilder("tr");
            var heading = Items.First();
            PropertyInfo[] properties = heading.GetType().GetProperties();
            foreach (var prop in properties)
            {
                var th = new TagBuilder("th");
                th.InnerHtml.Append(prop.Name);
              
                tr.InnerHtml.AppendHtml(th);
            }
            table.InnerHtml.AppendHtml(tr);
          
            foreach (var item in Items)
            {

                tr = new TagBuilder("tr");
                foreach (var prop in properties)
                {
                    var td = new TagBuilder("td");
                    td.InnerHtml.Append(prop.GetValue(item).ToString());
                    tr.InnerHtml.AppendHtml(td);
                }
                table.InnerHtml.AppendHtml(tr);
            }
            
            output.Content.AppendHtml(table.InnerHtml);
        }
コード例 #18
0
 public override void Process(TagHelperContext context, TagHelperOutput output)
 {
     if (!Condition)
     {
         output.SuppressOutput();
     }
 }
 public DefaultServerAutocompleteProcessor(TagHelperContext context, TagHelperOutput output, AutocompleteTagHelper tag, AutocompleteOptions options)
 {
     this.context = context;
     this.output = output;
     this.tag = tag;
     this.options = options;
 }
コード例 #20
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            StringBuilder sb = new StringBuilder();

            var urlHelper = _UrlHelper.GetUrlHelper(ViewContext);

            string menuUrl = urlHelper.Action(ActionName, ControllerName);

            output.TagName = "li";

            var a = new TagBuilder("a");
            a.MergeAttribute("href", $"{menuUrl}");
            a.MergeAttribute("title", MenuText);
            a.InnerHtml.Append(MenuText);

            var routeData = ViewContext.RouteData.Values;
            var currentController = routeData["controller"];
            var currentAction = routeData["action"];

            if (String.Equals(ActionName, currentAction as string, StringComparison.OrdinalIgnoreCase)
                && String.Equals(ControllerName, currentController as string, StringComparison.OrdinalIgnoreCase))
            {
                output.Attributes.Add("class", "active");
            }

            output.Content.AppendHtml(a);
        }
コード例 #21
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            base.Process(context, output);

            System.Text.StringBuilder sb = new System.Text.StringBuilder();

            var existAttribute = output.Attributes["class"];
            if (existAttribute != null)
            {
                sb.Append(existAttribute.Value.ToString());
                sb.Append(" ");
            }

            if (this.Condition)
            {
                if (!string.IsNullOrWhiteSpace(this.TrueClass))
                {
                    sb.Append(this.TrueClass);
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(this.FalseClass))
                {
                    sb.Append(this.FalseClass);
                }
            }

            if (sb.Length > 0)
            {
                output.Attributes.SetAttribute("class", sb.ToString());
            }
        }
コード例 #22
0
		/// <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)
		{
			// Get all items
			var allItems = (from i in ConditionalClasses
							where i.Value
							select i.Key).ToList();

			// No actions if no items
			if (allItems.Count == 0)
			{
				return;
			}

			// The original class attribute
			var classAttr = output.Attributes["class"];

			// If class attribute exists, merge it
			// Original value of the class attribute
			var originalClass = classAttr?.Value?.ToString();

			// append the original class value if not null
			if (!string.IsNullOrWhiteSpace(originalClass))
			{
				allItems.Add(originalClass);
			}

			// merge to the final class value
			var finalClass = string.Join(" ", allItems);


			// Replace original value
			output.Attributes.SetAttribute("class", finalClass);
		}
コード例 #23
0
ファイル: PrettyTagHelper.cs プロジェクト: cemalshukriev/Mvc
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            if (MakePretty.HasValue && !MakePretty.Value)
            {
                return;
            }

            if (output.TagName == null)
            {
                // Another tag helper e.g. TagHelperviewComponentTagHelper has suppressed the start and end tags.
                return;
            }

            string prettyStyle;

            if (PrettyTagStyles.TryGetValue(output.TagName, out prettyStyle))
            {
                var style = Style ?? string.Empty;
                if (!string.IsNullOrEmpty(style))
                {
                    style += ";";
                }

                output.Attributes.SetAttribute("style", style + prettyStyle);
            }
        }
コード例 #24
0
        /// <summary>
        /// Instantiates a new <see cref="TagHelperExecutionContext"/>.
        /// </summary>
        /// <param name="tagName">The HTML tag name in the Razor source.</param>
        /// <param name="tagMode">HTML syntax of the element in the Razor source.</param>
        /// <param name="items">The collection of items used to communicate with other
        /// <see cref="ITagHelper"/>s</param>
        /// <param name="uniqueId">An identifier unique to the HTML element this context is for.</param>
        /// <param name="executeChildContentAsync">A delegate used to execute the child content asynchronously.</param>
        /// <param name="startTagHelperWritingScope">
        /// A delegate used to start a writing scope in a Razor page and optionally override the page's
        /// <see cref="HtmlEncoder"/> within that scope.
        /// </param>
        /// <param name="endTagHelperWritingScope">A delegate used to end a writing scope in a Razor page.</param>
        public TagHelperExecutionContext(
            string tagName,
            TagMode tagMode,
            IDictionary<object, object> items,
            string uniqueId,
            Func<Task> executeChildContentAsync,
            Action<HtmlEncoder> startTagHelperWritingScope,
            Func<TagHelperContent> endTagHelperWritingScope)
        {
            if (startTagHelperWritingScope == null)
            {
                throw new ArgumentNullException(nameof(startTagHelperWritingScope));
            }

            if (endTagHelperWritingScope == null)
            {
                throw new ArgumentNullException(nameof(endTagHelperWritingScope));
            }

            _tagHelpers = new List<ITagHelper>();
            _allAttributes = new TagHelperAttributeList();

            Context = new TagHelperContext(_allAttributes, items, uniqueId);
            Output = new TagHelperOutput(tagName, new TagHelperAttributeList(), GetChildContentAsync)
            {
                TagMode = tagMode
            };

            Reinitialize(tagName, tagMode, items, uniqueId, executeChildContentAsync);

            _startTagHelperWritingScope = startTagHelperWritingScope;
            _endTagHelperWritingScope = endTagHelperWritingScope;
        }
コード例 #25
0
        public void Process_DoesNothingIfTagNameIsNull()
        {
            // Arrange
            var tagHelperOutput = new TagHelperOutput(
                tagName: null,
                attributes: new TagHelperAttributeList
                {
                    { "href", "~/home/index.html" }
                },
                getChildContentAsync: (useCachedResult, encoder) => Task.FromResult<TagHelperContent>(null));

            var tagHelper = new UrlResolutionTagHelper(Mock.Of<IUrlHelperFactory>(), new HtmlTestEncoder());
            var context = new TagHelperContext(
                allAttributes: new TagHelperAttributeList(
                    Enumerable.Empty<TagHelperAttribute>()),
                items: new Dictionary<object, object>(),
                uniqueId: "test");

            // Act
            tagHelper.Process(context, tagHelperOutput);

            // Assert
            var attribute = Assert.Single(tagHelperOutput.Attributes);
            Assert.Equal("href", attribute.Name, StringComparer.Ordinal);
            var attributeValue = Assert.IsType<string>(attribute.Value);
            Assert.Equal("~/home/index.html", attributeValue, StringComparer.Ordinal);
        }
コード例 #26
0
		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.AppendHtml(ifCommentStartPart);
			preContent.AppendHtml(Expression);
			preContent.AppendHtml(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.AppendHtml(endIfComment);
		}
コード例 #27
0
ファイル: SpeakerTagHelper.cs プロジェクト: Fixxup/fixxup.nl
        public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            var urlHelper = urlHelperFactory.GetUrlHelper(ViewContext);
            await Task.Run(() =>
            {
                output.TagMode = TagMode.SelfClosing;
                output.TagName = null;

                var speaker = speakerRepository.All.FirstOrDefault(_ => _.Name == Name);

                if (speaker == null)
                {
                    output.Content.SetHtmlContent($"<label>{Name}</label>");
                }
                else
                {

                    output.Content.SetHtmlContent($"<a href=\"{urlHelper.Link("SpeakerDetails", new { name = Name })}\">{Name}</a>");


                }
            });
            
         

        }
コード例 #28
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "textarea";

            output.AppendClass("form-control");

            base.Process(context, output);
        }
コード例 #29
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            output.TagName = "a";    // Replaces <email> with <a> tag

            var address = MailTo + "@" + EmailDomain;
            output.Attributes.SetAttribute("href", "mailto:" + address);
            output.Content.SetContent(address);
        }
コード例 #30
0
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            JsTree tree = For.Model as JsTree;

            output.Attributes.SetAttribute("class", (output.Attributes["class"]?.Value + " js-tree").Trim());
            output.Content.AppendHtml(HiddenIdsFor(tree));
            output.Content.AppendHtml(JsTreeFor(tree));
        }
コード例 #31
0
        public override async Task ProcessAsync(TagHelpers.TagHelperContext context, TagHelpers.TagHelperOutput output)
        {
            var content = await output.GetChildContentAsync();

            output.TagName = "svg";
            output.Attributes.Add("xmlns", svgNamespace);

            if (content.IsEmptyOrWhiteSpace)
            {
                output.Content.SetHtmlContent(Octicons.Instance.SpriteSheet);
            }
        }
コード例 #32
0
        public override void Process(TagHelpers.TagHelperContext context, TagHelpers.TagHelperOutput output)
        {
            var name    = Octicons.SymbolName(Symbol);
            var octicon = _octicons.Symbol(Symbol);

            //var symbolStartTag = $"<symbol viewBox=\"0 0 {octicon.Width} {octicon.Height}\" id=\"{name}\">";
            //var symbolEndTag = "</symbol>";

            output.TagName = "symbol";
            output.Attributes.Add("id", name);
            output.Attributes.Add("viewBox", $"0 0 {octicon.Width} {octicon.Height}");
            output.Content.SetHtmlContent(octicon.Path);
        }
コード例 #33
0
        public override void Process(TagHelpers.TagHelperContext context, TagHelpers.TagHelperOutput output)
        {
            var  useSpriteAttribute = new TagHelpers.TagHelperAttribute(UseSpriteAttributeName);
            bool useSprite          = context.AllAttributes.Contains(useSpriteAttribute);
            var  octicon            = _octicons.Symbol(Symbol);

            CalculateSize(octicon);
            output.TagName = "svg";
            output.Attributes.Remove(useSpriteAttribute);
            output.Attributes.Add("viewBox", ViewBox());
            output.Attributes.Add("width", Width.ToString());
            output.Attributes.Add("height", Height.ToString());
            output.Attributes.Add("version", Version);
            output.Attributes.SetAttribute("class", Classes(context));
            output.Content.SetHtmlContent(Svg(useSprite));
        }
コード例 #34
0
ファイル: TagHelper.cs プロジェクト: agr/AspNetCoreDebuggable
 /// <summary>
 /// Asynchronously 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>
 /// <returns>A <see cref="Task"/> that on completion updates the <paramref name="output"/>.</returns>
 /// <remarks>By default this calls into <see cref="Process"/>.</remarks>.
 public virtual Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
 {
     Process(context, output);
     return(TaskCache.CompletedTask);
 }
コード例 #35
0
ファイル: TagHelper.cs プロジェクト: agr/AspNetCoreDebuggable
 /// <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 virtual void Process(TagHelperContext context, TagHelperOutput output)
 {
 }
コード例 #36
0
 public static TagHelperContent Prepend(this TagHelperContent content, TagHelperOutput output) => content.Prepend(output.ToTagHelperContent());