本文整理汇总了C#中Microsoft.AspNet.Razor.Runtime.TagHelpers.TagHelperExecutionContext.AddMinimizedHtmlAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# TagHelperExecutionContext.AddMinimizedHtmlAttribute方法的具体用法?C# TagHelperExecutionContext.AddMinimizedHtmlAttribute怎么用?C# TagHelperExecutionContext.AddMinimizedHtmlAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.AspNet.Razor.Runtime.TagHelpers.TagHelperExecutionContext
的用法示例。
在下文中一共展示了TagHelperExecutionContext.AddMinimizedHtmlAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddMinimizedHtmlAttribute_MaintainsHTMLAttributes_SomeMinimized
public void AddMinimizedHtmlAttribute_MaintainsHTMLAttributes_SomeMinimized()
{
// Arrange
var executionContext = new TagHelperExecutionContext("input", tagMode: TagMode.SelfClosing);
var expectedAttributes = new TagHelperAttributeList
{
{ "class", "btn" },
{ "foo", "bar" }
};
expectedAttributes.Add(new TagHelperAttribute { Name = "checked", Minimized = true });
expectedAttributes.Add(new TagHelperAttribute { Name = "visible", Minimized = true });
// Act
executionContext.AddHtmlAttribute("class", "btn");
executionContext.AddHtmlAttribute("foo", "bar");
executionContext.AddMinimizedHtmlAttribute("checked");
executionContext.AddMinimizedHtmlAttribute("visible");
// Assert
Assert.Equal(
expectedAttributes,
executionContext.HTMLAttributes,
CaseSensitiveTagHelperAttributeComparer.Default);
}
示例2: ExecuteAsync
#pragma warning disable 1998
public override async Task ExecuteAsync()
{
__tagHelperRunner = __tagHelperRunner ?? new TagHelperRunner();
Instrumentation.BeginContext(25, 253, true);
WriteLiteral("\r\n<ul [item]=\"items\"></ul>\r\n<ul [(item)]=\"items\"></ul>\r\n<button (click)=\"doSometh" +
"ing()\">Click Me</button>\r\n<button (^click)=\"doSomething()\">Click Me</button>\r\n<t" +
"emplate *something=\"value\">\r\n</template>\r\n<div #local></div>\r\n<div #local=\"value" +
"\"></div>\r\n\r\n");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("ul", TagMode.StartTagAndEndTag, "test", async() => {
}
, StartTagHelperWritingScope, EndTagHelperWritingScope);
__CatchAllTagHelper = CreateTagHelper<CatchAllTagHelper>();
__tagHelperExecutionContext.Add(__CatchAllTagHelper);
__tagHelperExecutionContext.AddMinimizedHtmlAttribute("bound");
#line 12 "SymbolBoundAttributes.cshtml"
__CatchAllTagHelper.ListItems = items;
#line default
#line hidden
__tagHelperExecutionContext.AddTagHelperAttribute("[item]", __CatchAllTagHelper.ListItems);
__tagHelperExecutionContext.AddHtmlAttribute("[item]", Html.Raw("items"));
__tagHelperExecutionContext.Output = await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
Instrumentation.BeginContext(278, 45, false);
await WriteTagHelperAsync(__tagHelperExecutionContext);
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(323, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("ul", TagMode.StartTagAndEndTag, "test", async() => {
}
, StartTagHelperWritingScope, EndTagHelperWritingScope);
__CatchAllTagHelper = CreateTagHelper<CatchAllTagHelper>();
__tagHelperExecutionContext.Add(__CatchAllTagHelper);
__tagHelperExecutionContext.AddMinimizedHtmlAttribute("bound");
#line 13 "SymbolBoundAttributes.cshtml"
__CatchAllTagHelper.ArrayItems = items;
#line default
#line hidden
__tagHelperExecutionContext.AddTagHelperAttribute("[(item)]", __CatchAllTagHelper.ArrayItems);
__tagHelperExecutionContext.AddHtmlAttribute("[(item)]", Html.Raw("items"));
__tagHelperExecutionContext.Output = await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
Instrumentation.BeginContext(325, 49, false);
await WriteTagHelperAsync(__tagHelperExecutionContext);
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(374, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("button", TagMode.StartTagAndEndTag, "test", async() => {
Instrumentation.BeginContext(438, 8, true);
WriteLiteral("Click Me");
Instrumentation.EndContext();
}
, StartTagHelperWritingScope, EndTagHelperWritingScope);
__CatchAllTagHelper = CreateTagHelper<CatchAllTagHelper>();
__tagHelperExecutionContext.Add(__CatchAllTagHelper);
__tagHelperExecutionContext.AddMinimizedHtmlAttribute("bound");
#line 14 "SymbolBoundAttributes.cshtml"
__CatchAllTagHelper.Event1 = doSomething();
#line default
#line hidden
__tagHelperExecutionContext.AddTagHelperAttribute("(click)", __CatchAllTagHelper.Event1);
__tagHelperExecutionContext.AddHtmlAttribute("(click)", Html.Raw("doSomething()"));
__tagHelperExecutionContext.Output = await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
Instrumentation.BeginContext(376, 79, false);
await WriteTagHelperAsync(__tagHelperExecutionContext);
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(455, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("button", TagMode.StartTagAndEndTag, "test", async() => {
Instrumentation.BeginContext(521, 8, true);
WriteLiteral("Click Me");
Instrumentation.EndContext();
}
, StartTagHelperWritingScope, EndTagHelperWritingScope);
__CatchAllTagHelper = CreateTagHelper<CatchAllTagHelper>();
__tagHelperExecutionContext.Add(__CatchAllTagHelper);
__tagHelperExecutionContext.AddMinimizedHtmlAttribute("bound");
#line 15 "SymbolBoundAttributes.cshtml"
__CatchAllTagHelper.Event2 = doSomething();
#line default
#line hidden
__tagHelperExecutionContext.AddTagHelperAttribute("(^click)", __CatchAllTagHelper.Event2);
__tagHelperExecutionContext.AddHtmlAttribute("(^click)", Html.Raw("doSomething()"));
__tagHelperExecutionContext.Output = await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
Instrumentation.BeginContext(457, 81, false);
await WriteTagHelperAsync(__tagHelperExecutionContext);
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(538, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
//.........这里部分代码省略.........
示例3: AddMinimizedHtmlAttribute_MaintainsHTMLAttributes
public void AddMinimizedHtmlAttribute_MaintainsHTMLAttributes()
{
// Arrange
var executionContext = new TagHelperExecutionContext("input", tagMode: TagMode.StartTagOnly);
var expectedAttributes = new TagHelperAttributeList
{
["checked"] = new TagHelperAttribute { Name = "checked", Minimized = true },
["visible"] = new TagHelperAttribute { Name = "visible", Minimized = true }
};
// Act
executionContext.AddMinimizedHtmlAttribute("checked");
executionContext.AddMinimizedHtmlAttribute("visible");
// Assert
Assert.Equal(
expectedAttributes,
executionContext.HTMLAttributes,
CaseSensitiveTagHelperAttributeComparer.Default);
}
示例4: ExecuteAsync
#pragma warning disable 1998
public override async Task ExecuteAsync()
{
__tagHelperRunner = __tagHelperRunner ?? new TagHelperRunner();
Instrumentation.BeginContext(33, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("p", TagMode.StartTagAndEndTag, "test", async() => {
Instrumentation.BeginContext(64, 34, true);
WriteLiteral("\r\n <input nottaghelper />\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", TagMode.SelfClosing, "test", async() => {
}
, StartTagHelperWritingScope, EndTagHelperWritingScope);
__CatchAllTagHelper = CreateTagHelper<CatchAllTagHelper>();
__tagHelperExecutionContext.Add(__CatchAllTagHelper);
__tagHelperExecutionContext.AddHtmlAttribute("class", Html.Raw("btn"));
__tagHelperExecutionContext.AddMinimizedHtmlAttribute("catchall-unbound-required");
__tagHelperExecutionContext.Output = await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
Instrumentation.BeginContext(98, 59, false);
await WriteTagHelperAsync(__tagHelperExecutionContext);
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(157, 6, true);
WriteLiteral("\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", TagMode.SelfClosing, "test", async() => {
}
, StartTagHelperWritingScope, EndTagHelperWritingScope);
__InputTagHelper = CreateTagHelper<InputTagHelper>();
__tagHelperExecutionContext.Add(__InputTagHelper);
__CatchAllTagHelper = CreateTagHelper<CatchAllTagHelper>();
__tagHelperExecutionContext.Add(__CatchAllTagHelper);
__tagHelperExecutionContext.AddHtmlAttribute("class", Html.Raw("btn"));
__tagHelperExecutionContext.AddMinimizedHtmlAttribute("catchall-unbound-required");
__tagHelperExecutionContext.AddMinimizedHtmlAttribute("input-unbound-required");
__InputTagHelper.BoundRequiredString = "hello";
__tagHelperExecutionContext.AddTagHelperAttribute("input-bound-required-string", __InputTagHelper.BoundRequiredString);
__tagHelperExecutionContext.Output = await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
Instrumentation.BeginContext(163, 119, false);
await WriteTagHelperAsync(__tagHelperExecutionContext);
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(282, 6, true);
WriteLiteral("\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", TagMode.SelfClosing, "test", async() => {
}
, StartTagHelperWritingScope, EndTagHelperWritingScope);
__InputTagHelper = CreateTagHelper<InputTagHelper>();
__tagHelperExecutionContext.Add(__InputTagHelper);
__CatchAllTagHelper = CreateTagHelper<CatchAllTagHelper>();
__tagHelperExecutionContext.Add(__CatchAllTagHelper);
__tagHelperExecutionContext.AddHtmlAttribute("class", Html.Raw("btn"));
__tagHelperExecutionContext.AddMinimizedHtmlAttribute("catchall-unbound-required");
__tagHelperExecutionContext.AddMinimizedHtmlAttribute("input-unbound-required");
__CatchAllTagHelper.BoundRequiredString = "world";
__tagHelperExecutionContext.AddTagHelperAttribute("catchall-bound-string", __CatchAllTagHelper.BoundRequiredString);
__InputTagHelper.BoundRequiredString = "hello2";
__tagHelperExecutionContext.AddTagHelperAttribute("input-bound-required-string", __InputTagHelper.BoundRequiredString);
__tagHelperExecutionContext.Output = await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
Instrumentation.BeginContext(288, 176, false);
await WriteTagHelperAsync(__tagHelperExecutionContext);
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(464, 6, true);
WriteLiteral("\r\n ");
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.Begin("input", TagMode.SelfClosing, "test", async() => {
}
, StartTagHelperWritingScope, EndTagHelperWritingScope);
__InputTagHelper = CreateTagHelper<InputTagHelper>();
__tagHelperExecutionContext.Add(__InputTagHelper);
__CatchAllTagHelper = CreateTagHelper<CatchAllTagHelper>();
__tagHelperExecutionContext.Add(__CatchAllTagHelper);
__tagHelperExecutionContext.AddHtmlAttribute("class", Html.Raw("btn"));
__tagHelperExecutionContext.AddHtmlAttribute("catchall-unbound-required", Html.Raw("hello"));
__tagHelperExecutionContext.AddHtmlAttribute("input-unbound-required", Html.Raw("hello2"));
__tagHelperExecutionContext.AddMinimizedHtmlAttribute("catchall-unbound-required");
__InputTagHelper.BoundRequiredString = "world";
__tagHelperExecutionContext.AddTagHelperAttribute("input-bound-required-string", __InputTagHelper.BoundRequiredString);
__tagHelperExecutionContext.Output = await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
Instrumentation.BeginContext(470, 206, false);
await WriteTagHelperAsync(__tagHelperExecutionContext);
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.End();
Instrumentation.BeginContext(676, 2, true);
WriteLiteral("\r\n");
Instrumentation.EndContext();
}
, StartTagHelperWritingScope, EndTagHelperWritingScope);
__CatchAllTagHelper = CreateTagHelper<CatchAllTagHelper>();
__tagHelperExecutionContext.Add(__CatchAllTagHelper);
__tagHelperExecutionContext.AddMinimizedHtmlAttribute("catchall-unbound-required");
__tagHelperExecutionContext.Output = await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
Instrumentation.BeginContext(35, 647, false);
await WriteTagHelperAsync(__tagHelperExecutionContext);
Instrumentation.EndContext();
__tagHelperExecutionContext = __tagHelperScopeManager.End();
}