使用 ASP.NET Core Tag Helpers,Process 方法是调用 ProcessAsync 还是其他方式?
With ASP.NET Core Tag Helpers, does the Process method Call ProcessAsync or the other way?
我在 asp.net MVC 源中找不到 TagHelper 方法的源代码。我试图了解两者之间的关系。我注意到 ITagHelper 接口只需要 ProcessAsync 所以我认为 Process 必须以某种方式调用 ProcessAsync 但我想在源代码中找到它以便我更好地理解。
https://docs.microsoft.com/en-us/aspnet/core/api/microsoft.aspnetcore.razor.taghelpers.itaghelper
我认为您看到的 Process
方法实际上来自 TagHelper
which implements the ITagHelper
接口并将 Process
添加为虚拟方法。 XML 评论说:
Synchronously executes the TagHelper with the given context and output.
所以如何实现这些方法完全取决于标签助手。正如您所建议的,一种选择是让一个人打电话给另一个人。实现完全取决于组件本身。但是,针对异步方法的 XML 评论指出:
ProcessAsync: By default this calls into Process
并且 the code 展示了它的工作原理:
public virtual Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
Process(context, output);
return TaskCache.CompletedTask;
}
我在 asp.net MVC 源中找不到 TagHelper 方法的源代码。我试图了解两者之间的关系。我注意到 ITagHelper 接口只需要 ProcessAsync 所以我认为 Process 必须以某种方式调用 ProcessAsync 但我想在源代码中找到它以便我更好地理解。
https://docs.microsoft.com/en-us/aspnet/core/api/microsoft.aspnetcore.razor.taghelpers.itaghelper
我认为您看到的 Process
方法实际上来自 TagHelper
which implements the ITagHelper
接口并将 Process
添加为虚拟方法。 XML 评论说:
Synchronously executes the TagHelper with the given context and output.
所以如何实现这些方法完全取决于标签助手。正如您所建议的,一种选择是让一个人打电话给另一个人。实现完全取决于组件本身。但是,针对异步方法的 XML 评论指出:
ProcessAsync: By default this calls into
Process
并且 the code 展示了它的工作原理:
public virtual Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
Process(context, output);
return TaskCache.CompletedTask;
}