Use nameof when initializing `GeneratedTagHelperContext`
nits: - missing blank line before a comment - cleanup line breaks in `RazorPage.CreateTagHelper`
This commit is contained in:
parent
9899cb336a
commit
3290791c5f
|
|
@ -36,6 +36,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly IFileSystem _fileSystem;
|
private readonly IFileSystem _fileSystem;
|
||||||
|
|
||||||
// CodeGenerationContext.DefaultBaseClass is set to MyBaseType<dynamic>.
|
// CodeGenerationContext.DefaultBaseClass is set to MyBaseType<dynamic>.
|
||||||
// This field holds the type name without the generic decoration (MyBaseType)
|
// This field holds the type name without the generic decoration (MyBaseType)
|
||||||
private readonly string _baseType;
|
private readonly string _baseType;
|
||||||
|
|
@ -85,11 +86,28 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
defineSectionMethodName: "DefineSection",
|
defineSectionMethodName: "DefineSection",
|
||||||
generatedTagHelperContext: new GeneratedTagHelperContext
|
generatedTagHelperContext: new GeneratedTagHelperContext
|
||||||
{
|
{
|
||||||
RunnerTypeName = typeof(TagHelperRunner).FullName,
|
|
||||||
ScopeManagerTypeName = typeof(TagHelperScopeManager).FullName,
|
|
||||||
ExecutionContextTypeName = typeof(TagHelperExecutionContext).FullName,
|
ExecutionContextTypeName = typeof(TagHelperExecutionContext).FullName,
|
||||||
|
ExecutionContextAddMethodName = nameof(TagHelperExecutionContext.Add),
|
||||||
|
ExecutionContextAddTagHelperAttributeMethodName =
|
||||||
|
nameof(TagHelperExecutionContext.AddTagHelperAttribute),
|
||||||
|
ExecutionContextAddHtmlAttributeMethodName = nameof(TagHelperExecutionContext.AddHtmlAttribute),
|
||||||
|
ExecutionContextOutputPropertyName = nameof(TagHelperExecutionContext.Output),
|
||||||
|
|
||||||
|
RunnerTypeName = typeof(TagHelperRunner).FullName,
|
||||||
|
RunnerRunAsyncMethodName = nameof(TagHelperRunner.RunAsync),
|
||||||
|
|
||||||
|
ScopeManagerTypeName = typeof(TagHelperScopeManager).FullName,
|
||||||
|
ScopeManagerBeginMethodName = nameof(TagHelperScopeManager.Begin),
|
||||||
|
ScopeManagerEndMethodName = nameof(TagHelperScopeManager.End),
|
||||||
|
|
||||||
|
OutputGenerateStartTagMethodName = nameof(TagHelperOutput.GenerateStartTag),
|
||||||
|
OutputGenerateContentMethodName = nameof(TagHelperOutput.GenerateContent),
|
||||||
|
OutputGenerateEndTagMethodName = nameof(TagHelperOutput.GenerateEndTag),
|
||||||
|
|
||||||
|
// Can't use nameof because RazorPage is not accessible here.
|
||||||
|
CreateTagHelperMethodName = "CreateTagHelper",
|
||||||
StartWritingScopeMethodName = "StartWritingScope",
|
StartWritingScopeMethodName = "StartWritingScope",
|
||||||
EndWritingScopeMethodName = "EndWritingScope"
|
EndWritingScopeMethodName = "EndWritingScope",
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
ResolveUrlMethodName = "Href",
|
ResolveUrlMethodName = "Href",
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,8 @@ namespace Microsoft.AspNet.Mvc.Razor
|
||||||
public TTagHelper CreateTagHelper<TTagHelper>() where TTagHelper : ITagHelper
|
public TTagHelper CreateTagHelper<TTagHelper>() where TTagHelper : ITagHelper
|
||||||
{
|
{
|
||||||
var tagHelper = TypeActivator.CreateInstance<TTagHelper>(ViewContext.HttpContext.RequestServices);
|
var tagHelper = TypeActivator.CreateInstance<TTagHelper>(ViewContext.HttpContext.RequestServices);
|
||||||
var hasViewContext = tagHelper as ICanHasViewContext;
|
|
||||||
|
|
||||||
|
var hasViewContext = tagHelper as ICanHasViewContext;
|
||||||
hasViewContext?.Contextualize(ViewContext);
|
hasViewContext?.Contextualize(ViewContext);
|
||||||
|
|
||||||
return tagHelper;
|
return tagHelper;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue