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

C# TagHelperAttributeList类代码示例

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

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



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

示例1: TagHelperExecutionContext

        /// <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;
        }
开发者ID:x-strong,项目名称:Razor,代码行数:47,代码来源:TagHelperExecutionContext.cs


示例2: DetermineMode_SetsModeWithHigestValue

        public void DetermineMode_SetsModeWithHigestValue()
        {
            // Arrange
            var modeInfos = new[]
            {
                new ModeAttributes<Mode>(Mode.A, new[] { "first-attr" }),
                new ModeAttributes<Mode>(Mode.B, new[] { "first-attr", "second-attr" }),
                new ModeAttributes<Mode>(Mode.D, new[] { "second-attr", "third-attr" }),
                new ModeAttributes<Mode>(Mode.C, new[] { "first-attr", "second-attr", "third-attr" }),
            };
            var attributes = new TagHelperAttributeList
            {
                new TagHelperAttribute("first-attr", "value"),
                new TagHelperAttribute("second-attr", "value"),
                new TagHelperAttribute("third-attr", "value"),
                new TagHelperAttribute("not-in-any-mode", "value")
            };
            var context = MakeTagHelperContext(attributes);

            // Act
            Mode result;
            var modeMatch = AttributeMatcher.TryDetermineMode(context, modeInfos, Compare, out result);

            // Assert
            Assert.True(modeMatch);
            Assert.Equal(Mode.D, result);
        }
开发者ID:ymd1223,项目名称:Mvc,代码行数:27,代码来源:AttributeMatcherTest.cs


示例3: TagHelperOutput

 /// <summary>
 /// Instantiates a new instance of <see cref="TagHelperOutput"/>.
 /// </summary>
 /// <param name="tagName">The HTML element's tag name.</param>
 /// <param name="attributes">The HTML attributes.</param>
 public TagHelperOutput(
     string tagName,
     [NotNull] TagHelperAttributeList attributes)
 {
     TagName = tagName;
     Attributes = new TagHelperAttributeList(attributes);
 }
开发者ID:antiufo,项目名称:Razor,代码行数:12,代码来源:TagHelperOutput.cs


示例4: DetermineMode_FindsFullModeMatchWithMultipleAttributes

        public void DetermineMode_FindsFullModeMatchWithMultipleAttributes()
        {
            // Arrange
            var modeInfo = new[]
            {
                ModeAttributes.Create("mode0", new [] { "first-attr", "second-attr" })
            };
            var attributes = new TagHelperAttributeList
            {
                ["first-attr"] = "value",
                ["second-attr"] = "value",
                ["not-in-any-mode"] = "value"
            };
            var context = MakeTagHelperContext(attributes);

            // Act
            var modeMatch = AttributeMatcher.DetermineMode(context, modeInfo);

            // Assert
            Assert.Collection(modeMatch.FullMatches, match =>
            {
                Assert.Equal("mode0", match.Mode);
                Assert.Collection(match.PresentAttributes,
                    attribute => Assert.Equal("first-attr", attribute),
                    attribute => Assert.Equal("second-attr", attribute)
                );
            });
            Assert.Empty(modeMatch.PartialMatches);
            Assert.Empty(modeMatch.PartiallyMatchedAttributes);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:30,代码来源:AttributeMatcherTest.cs


示例5: CheckBoxHandlesMultipleAttributesSameNameCorrectly

        public async Task CheckBoxHandlesMultipleAttributesSameNameCorrectly(
            TagHelperAttributeList outputAttributes,
            string expectedAttributeString)
        {
            // Arrange
            var originalContent = "original content";
            var originalTagName = "not-input";
            var expectedContent = $"{originalContent}<input {expectedAttributeString} id=\"HtmlEncode[[IsACar]]\" " +
                "name=\"HtmlEncode[[IsACar]]\" type=\"HtmlEncode[[checkbox]]\" value=\"HtmlEncode[[true]]\" />" +
                "<input name=\"HtmlEncode[[IsACar]]\" type=\"HtmlEncode[[hidden]]\" value=\"HtmlEncode[[false]]\" />";

            var context = new TagHelperContext(
                allAttributes: new ReadOnlyTagHelperAttributeList<IReadOnlyTagHelperAttribute>(
                    Enumerable.Empty<IReadOnlyTagHelperAttribute>()),
                items: new Dictionary<object, object>(),
                uniqueId: "test",
                getChildContentAsync: useCachedResult => Task.FromResult<TagHelperContent>(result: null));
            var output = new TagHelperOutput(originalTagName, outputAttributes)
            {
                TagMode = TagMode.SelfClosing,
            };
            output.Content.SetContent(originalContent);
            var htmlGenerator = new TestableHtmlGenerator(new EmptyModelMetadataProvider());
            var tagHelper = GetTagHelper(htmlGenerator, model: false, propertyName: nameof(Model.IsACar));

            // Act
            await tagHelper.ProcessAsync(context, output);

            // Assert
            Assert.Empty(output.Attributes); // Moved to Content and cleared
            Assert.Equal(expectedContent, HtmlContentUtilities.HtmlContentToString(output.Content));
            Assert.Equal(TagMode.SelfClosing, output.TagMode);
            Assert.Null(output.TagName); // Cleared
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:34,代码来源:InputTagHelperTest.cs


示例6: DetermineMode_SetsModeIfAllAttributesMatch

        public void DetermineMode_SetsModeIfAllAttributesMatch()
        {
            // Arrange
            var modeInfos = new[]
            {
                new ModeAttributes<Mode>(Mode.A, new[] { "a-required-attributes" }),
                new ModeAttributes<Mode>(Mode.B, new[] { "first-attr", "second-attr" }),
                new ModeAttributes<Mode>(Mode.C, new[] { "first-attr", "third-attr" }),
            };
            var attributes = new TagHelperAttributeList
            {
                ["first-attr"] = "value",
                ["second-attr"] = "value",
                ["not-in-any-mode"] = "value"
            };
            var context = MakeTagHelperContext(attributes);

            // Act
            Mode result;
            var modeMatch = AttributeMatcher.TryDetermineMode(context, modeInfos, Compare, out result);

            // Assert
            Assert.True(modeMatch);
            Assert.Equal(Mode.B, result);
        }
开发者ID:phinq19,项目名称:git_example,代码行数:25,代码来源:AttributeMatcherTest.cs


示例7: Reinitialize_AllowsContextToBeReused

        public void Reinitialize_AllowsContextToBeReused()
        {
            // Arrange
            var initialUniqueId = "123";
            var expectedUniqueId = "456";
            var initialItems = new Dictionary<object, object>
            {
                { "test-entry", 1234 }
            };
            var expectedItems = new Dictionary<object, object>
            {
                { "something", "new" }
            };
            var initialAttributes = new TagHelperAttributeList
            {
                { "name", "value" }
            };
            var context = new TagHelperContext(initialAttributes, initialItems, initialUniqueId);

            // Act
            context.Reinitialize(expectedItems, expectedUniqueId);

            // Assert
            Assert.Same(expectedItems, context.Items);
            Assert.Equal(expectedUniqueId, context.UniqueId);
            Assert.Empty(context.AllAttributes);
        }
开发者ID:,项目名称:,代码行数:27,代码来源:


示例8: Process_SrcDefaultsToTagHelperOutputSrcAttributeAddedByOtherTagHelper

        public void Process_SrcDefaultsToTagHelperOutputSrcAttributeAddedByOtherTagHelper(
            string src,
            string srcOutput,
            string expectedSrcPrefix)
        {
            // Arrange
            var allAttributes = new TagHelperAttributeList(
                new TagHelperAttributeList
                {
                    { "alt", new HtmlString("Testing") },
                    { "asp-append-version", true },
                });
            var context = MakeTagHelperContext(allAttributes);
            var outputAttributes = new TagHelperAttributeList
                {
                    { "alt", new HtmlString("Testing") },
                    { "src", srcOutput },
                };
            var output = new TagHelperOutput(
                "img",
                outputAttributes,
                getChildContentAsync: (useCachedResult, encoder) => Task.FromResult<TagHelperContent>(
                    new DefaultTagHelperContent()));
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();
            var urlHelper = new Mock<IUrlHelper>();

            // Ensure expanded path does not look like an absolute path on Linux, avoiding
            // https://github.com/aspnet/External/issues/21
            urlHelper
                .Setup(urlhelper => urlhelper.Content(It.IsAny<string>()))
                .Returns(new Func<string, string>(url => url.Replace("~/", "virtualRoot/")));
            var urlHelperFactory = new Mock<IUrlHelperFactory>();
            urlHelperFactory
                .Setup(f => f.GetUrlHelper(It.IsAny<ActionContext>()))
                .Returns(urlHelper.Object);

            var helper = new ImageTagHelper(
                hostingEnvironment,
                MakeCache(),
                new HtmlTestEncoder(),
                urlHelperFactory.Object)
            {
                ViewContext = viewContext,
                AppendVersion = true,
                Src = src,
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(
                expectedSrcPrefix + "?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk",
                (string)output.Attributes["src"].Value,
                StringComparer.Ordinal);
        }
开发者ID:cemalshukriev,项目名称:Mvc,代码行数:57,代码来源:ImageTagHelperTest.cs


示例9: Process_HrefDefaultsToTagHelperOutputHrefAttributeAddedByOtherTagHelper

        public void Process_HrefDefaultsToTagHelperOutputHrefAttributeAddedByOtherTagHelper(
            string href,
            string hrefOutput,
            string expectedHrefPrefix)
        {
            // Arrange
            var allAttributes = new TagHelperAttributeList(
                new TagHelperAttributeList
                {
                    { "rel", new HtmlString("stylesheet") },
                    { "asp-append-version", true },
                });
            var context = MakeTagHelperContext(allAttributes);
            var outputAttributes = new TagHelperAttributeList
                {
                    { "rel", new HtmlString("stylesheet") },
                    { "href", hrefOutput },
                };
            var output = MakeTagHelperOutput("link", outputAttributes);
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();
            var urlHelper = new Mock<IUrlHelper>();

            // Ensure expanded path does not look like an absolute path on Linux, avoiding
            // https://github.com/aspnet/External/issues/21
            urlHelper
                .Setup(urlhelper => urlhelper.Content(It.IsAny<string>()))
                .Returns(new Func<string, string>(url => url.Replace("~/", "virtualRoot/")));
            var urlHelperFactory = new Mock<IUrlHelperFactory>();
            urlHelperFactory
                .Setup(f => f.GetUrlHelper(It.IsAny<ActionContext>()))
                .Returns(urlHelper.Object);

            var helper = new LinkTagHelper(
                hostingEnvironment,
                MakeCache(),
                new HtmlTestEncoder(),
                new JavaScriptTestEncoder(),
                urlHelperFactory.Object)
            {
                ViewContext = viewContext,
                AppendVersion = true,
                Href = href,
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(
                expectedHrefPrefix + "?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk",
                (string)output.Attributes["href"].Value,
                StringComparer.Ordinal);
        }
开发者ID:phinq19,项目名称:git_example,代码行数:54,代码来源:LinkTagHelperTest.cs


示例10: TagHelperOutput

        /// <summary>
        /// Instantiates a new instance of <see cref="TagHelperOutput"/>.
        /// </summary>
        /// <param name="tagName">The HTML element's tag name.</param>
        /// <param name="attributes">The HTML attributes.</param>
        public TagHelperOutput(
            string tagName,
            TagHelperAttributeList attributes)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException(nameof(attributes));
            }

            TagName = tagName;
            Attributes = new TagHelperAttributeList(attributes);
        }
开发者ID:rahulchrty,项目名称:Razor,代码行数:17,代码来源:TagHelperOutput.cs


示例11: IntIndexer_Getter_ThrowsIfIndexInvalid

        public void IntIndexer_Getter_ThrowsIfIndexInvalid(int index)
        {
            // Arrange
            var attributes = new TagHelperAttributeList(new[]
                {
                    new TagHelperAttribute("A", "AV"),
                    new TagHelperAttribute("B", "BV")
                });

            // Act & Assert
            var exception = Assert.Throws<ArgumentOutOfRangeException>("index", () => attributes[index]);
        }
开发者ID:huoxudong125,项目名称:Razor,代码行数:12,代码来源:TagHelperAttributeListTest.cs


示例12: Process_SrcDefaultsToTagHelperOutputSrcAttributeAddedByOtherTagHelper

        public void Process_SrcDefaultsToTagHelperOutputSrcAttributeAddedByOtherTagHelper(
            string src,
            string srcOutput,
            string expectedSrcPrefix)
        {
            // Arrange
            var allAttributes = new TagHelperAttributeList(
                new TagHelperAttributeList
                {
                    { "type", new HtmlString("text/javascript") },
                    { "asp-append-version", true },
                });
            var context = MakeTagHelperContext(allAttributes);
            var outputAttributes = new TagHelperAttributeList
                {
                    { "type", new HtmlString("text/javascript") },
                    { "src", srcOutput },
                };
            var output = MakeTagHelperOutput("script", outputAttributes);
            var logger = new Mock<ILogger<ScriptTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();
            var urlHelper = new Mock<IUrlHelper>();

            // Ensure expanded path does not look like an absolute path on Linux, avoiding
            // https://github.com/aspnet/External/issues/21
            urlHelper
                .Setup(urlhelper => urlhelper.Content(It.IsAny<string>()))
                .Returns(new Func<string, string>(url => url.Replace("~/", "virtualRoot/")));

            var helper = new ScriptTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder(),
                urlHelper.Object)
            {
                ViewContext = viewContext,
                AppendVersion = true,
                Src = src,
            };

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(
                expectedSrcPrefix + "?v=f4OxZX_x_FO5LcGBSKHWXfwtSx-j1ncoSt3SABJtkGk",
                (string)output.Attributes["src"].Value,
                StringComparer.Ordinal);
        }
开发者ID:4myBenefits,项目名称:Mvc,代码行数:52,代码来源:ScriptTagHelperTest.cs


示例13: IntIndexer_GetsExpectedAttribute

        public void IntIndexer_GetsExpectedAttribute(
            IEnumerable<TagHelperAttribute> initialAttributes,
            int indexToLookup,
            TagHelperAttribute expectedAttribute)
        {
            // Arrange
            var attributes = new TagHelperAttributeList(initialAttributes);

            // Act
            var attribute = attributes[indexToLookup];

            // Assert
            Assert.Equal(expectedAttribute, attribute, CaseSensitiveTagHelperAttributeComparer.Default);
        }
开发者ID:huoxudong125,项目名称:Razor,代码行数:14,代码来源:TagHelperAttributeListTest.cs


示例14: HandlesMultipleAttributesSameNameCorrectly

        public void HandlesMultipleAttributesSameNameCorrectly(TagHelperAttributeList outputAttributes)
        {
            // Arrange
            var allAttributes = new TagHelperAttributeList(
                outputAttributes.Concat(
                    new TagHelperAttributeList
                    {
                        { "rel", new HtmlString("stylesheet") },
                        { "href", "test.css" },
                        { "asp-fallback-href", "test.css" },
                        { "asp-fallback-test-class", "hidden" },
                        { "asp-fallback-test-property", "visibility" },
                        { "asp-fallback-test-value", "hidden" },
                    }));
            var context = MakeTagHelperContext(allAttributes);
            var combinedOutputAttributes = new TagHelperAttributeList(
                outputAttributes.Concat(
                    new[]
                    {
                        new TagHelperAttribute("rel", new HtmlString("stylesheet"))
                    }));
            var output = MakeTagHelperOutput("link", combinedOutputAttributes);
            var logger = new Mock<ILogger<LinkTagHelper>>();
            var hostingEnvironment = MakeHostingEnvironment();
            var viewContext = MakeViewContext();

            var helper = new LinkTagHelper(
                logger.Object,
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder(),
                MakeUrlHelper())
            {
                ViewContext = viewContext,
                FallbackHref = "test.css",
                FallbackTestClass = "hidden",
                FallbackTestProperty = "visibility",
                FallbackTestValue = "hidden",
                Href = "test.css",
            };
            var expectedAttributes = new TagHelperAttributeList(output.Attributes);
            expectedAttributes.Add(new TagHelperAttribute("href", "test.css"));

            // Act
            helper.Process(context, output);

            // Assert
            Assert.Equal(expectedAttributes, output.Attributes);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:50,代码来源:LinkTagHelperTest.cs


示例15: IntIndexer_SetsAttributeAtExpectedIndex

        public void IntIndexer_SetsAttributeAtExpectedIndex(
            IEnumerable<TagHelperAttribute> initialAttributes,
            int indexToSet,
            TagHelperAttribute setValue,
            IEnumerable<TagHelperAttribute> expectedAttributes)
        {
            // Arrange
            var attributes = new TagHelperAttributeList(initialAttributes);

            // Act
            attributes[indexToSet] = setValue;

            // Assert
            Assert.Equal(expectedAttributes, attributes, CaseSensitiveTagHelperAttributeComparer.Default);
        }
开发者ID:huoxudong125,项目名称:Razor,代码行数:15,代码来源:TagHelperAttributeListTest.cs


示例16: Reinitialize_AllowsOutputToBeReused

        public async Task Reinitialize_AllowsOutputToBeReused()
        {
            // Arrange
            var initialOutputChildContent = new DefaultTagHelperContent();
            initialOutputChildContent.SetContent("Initial output content.");
            var expectedGetChildContentContent = "Initial get child content content";
            var initialGetChildContent = new DefaultTagHelperContent();
            initialGetChildContent.SetContent(expectedGetChildContentContent);
            Func<bool, HtmlEncoder, Task<TagHelperContent>> initialGetChildContentAsync =
                (useCachedResult, encoder) => Task.FromResult<TagHelperContent>(initialGetChildContent);
            var initialTagMode = TagMode.StartTagOnly;
            var initialAttributes = new TagHelperAttributeList
            {
                { "name", "value" }
            };
            var initialTagName = "initialTagName";
            var output = new TagHelperOutput(initialTagName, initialAttributes, initialGetChildContentAsync)
            {
                TagMode = initialTagMode,
                Content = initialOutputChildContent,
            };
            output.PreContent.SetContent("something");
            output.PostContent.SetContent("something");
            output.PreElement.SetContent("something");
            output.PostElement.SetContent("something");
            var expectedTagName = "newTagName";
            var expectedTagMode = TagMode.SelfClosing;

            // Act
            output.Reinitialize(expectedTagName, expectedTagMode);

            // Assert
            Assert.Equal(expectedTagName, output.TagName);
            Assert.Equal(expectedTagMode, output.TagMode);
            Assert.Empty(output.Attributes);

            var getChildContent = await output.GetChildContentAsync();
            var content = getChildContent.GetContent();

            // We're expecting the initial child content here because normally the TagHelper infrastructure would
            // swap out the inner workings of GetChildContentAsync to work with its reinitialized state.
            Assert.Equal(expectedGetChildContentContent, content);
            Assert.False(output.PreContent.IsModified);
            Assert.False(output.PostContent.IsModified);
            Assert.False(output.PreElement.IsModified);
            Assert.False(output.PostElement.IsModified);
        }
开发者ID:cjqian,项目名称:Razor,代码行数:47,代码来源:TagHelperOutputTest.cs


示例17: HandlesMultipleAttributesSameNameCorrectly

        public async Task HandlesMultipleAttributesSameNameCorrectly(
            TagHelperAttributeList outputAttributes,
            string expectedAttributeString)
        {
            // Arrange
            var allAttributes = new TagHelperAttributeList(
                outputAttributes.Concat(
                    new TagHelperAttributeList
                    {
                        ["data-extra"] = "something",
                        ["src"] = "/blank.js",
                        ["asp-fallback-src"] = "http://www.example.com/blank.js",
                        ["asp-fallback-test"] = "isavailable()",
                    }));
            var tagHelperContext = MakeTagHelperContext(allAttributes);
            var viewContext = MakeViewContext();
            var combinedOutputAttributes = new TagHelperAttributeList(
                outputAttributes.Concat(
                    new[]
                    {
                        new TagHelperAttribute("data-extra", new HtmlString("something"))
                    }));
            var output = MakeTagHelperOutput("script", combinedOutputAttributes);
            var hostingEnvironment = MakeHostingEnvironment();

            var helper = new ScriptTagHelper(
                CreateLogger(),
                hostingEnvironment,
                MakeCache(),
                new CommonTestEncoder(),
                new CommonTestEncoder())
            {
                ViewContext = viewContext,
                FallbackSrc = "~/blank.js",
                FallbackTestExpression = "http://www.example.com/blank.js",
                Src = "/blank.js",
            };

            // Act
            await helper.ProcessAsync(tagHelperContext, output);

            // Assert
            Assert.StartsWith(
                "<script " + expectedAttributeString + " data-extra=\"something\" " +
                "src=\"HtmlEncode[[/blank.js]]\"",
                output.Content.GetContent());
        }
开发者ID:notami18,项目名称:Mvc,代码行数:47,代码来源:ScriptTagHelperTest.cs


示例18: TagHelperOutput

        /// <summary>
        /// Instantiates a new instance of <see cref="TagHelperOutput"/>.
        /// </summary>
        /// <param name="tagName">The HTML element's tag name.</param>
        /// <param name="attributes">The HTML attributes.</param>
        /// <param name="getChildContentAsync">A delegate used to execute and retrieve the rendered child content
        /// asynchronously.</param>
        public TagHelperOutput(
            string tagName,
            TagHelperAttributeList attributes,
            Func<bool, Task<TagHelperContent>> getChildContentAsync)
        {
            if (attributes == null)
            {
                throw new ArgumentNullException(nameof(attributes));
            }

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

            TagName = tagName;
            Attributes = new TagHelperAttributeList(attributes);
            _getChildContentAsync = getChildContentAsync;
        }
开发者ID:huoxudong125,项目名称:Razor,代码行数:26,代码来源:TagHelperOutput.cs


示例19: TagHelperExecutionContext

        /// <summary>
        /// Instantiates a new <see cref="TagHelperExecutionContext"/>.
        /// </summary>
        /// <param name="tagName">The HTML tag name in the Razor source.</param>
        /// <param name="selfClosing">
        /// <see cref="bool"/> indicating whether or not the tag in the Razor source was self-closing.</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.</param>
        /// <param name="endTagHelperWritingScope">A delegate used to end a writing scope in a Razor page.</param>
        public TagHelperExecutionContext(
            [NotNull] string tagName,
            bool selfClosing,
            [NotNull] IDictionary<object, object> items,
            [NotNull] string uniqueId,
            [NotNull] Func<Task> executeChildContentAsync,
            [NotNull] Action startTagHelperWritingScope,
            [NotNull] Func<TagHelperContent> endTagHelperWritingScope)
        {
            _tagHelpers = new List<ITagHelper>();
            _executeChildContentAsync = executeChildContentAsync;
            _startTagHelperWritingScope = startTagHelperWritingScope;
            _endTagHelperWritingScope = endTagHelperWritingScope;

            SelfClosing = selfClosing;
            HTMLAttributes = new TagHelperAttributeList();
            AllAttributes = new TagHelperAttributeList();
            TagName = tagName;
            Items = items;
            UniqueId = uniqueId;
        }
开发者ID:rohitpoudel,项目名称:Razor,代码行数:33,代码来源:TagHelperExecutionContext.cs


示例20: TryDetermineMode_ReturnsFalseIfNoAttributeMatchesAllRequiredAttributes

        public void TryDetermineMode_ReturnsFalseIfNoAttributeMatchesAllRequiredAttributes(string[] modeAttributes)
        {
            // Arrange
            var modeInfos = new[]
            {
                new ModeAttributes<Mode>(Mode.A, modeAttributes)
            };
            var attributes = new TagHelperAttributeList
            {
                ["first-attr"] = "value",
                ["not-in-any-mode"] = "value"
            };
            var context = MakeTagHelperContext(attributes);

            // Act
            Mode result;
            var modeMatch = AttributeMatcher.TryDetermineMode(context, modeInfos, Compare, out result);

            // Assert
            Assert.False(modeMatch);
        }
开发者ID:phinq19,项目名称:git_example,代码行数:21,代码来源:AttributeMatcherTest.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# TagInfo类代码示例发布时间:2022-05-24
下一篇:
C# TagData类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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