|
|
@ -34,9 +34,9 @@ public class RazorTemplateRenderingEngine : TemplateRenderingEngineBase, ITransi |
|
|
|
|
|
|
|
|
public override async Task<string> RenderAsync( |
|
|
public override async Task<string> RenderAsync( |
|
|
[NotNull] string templateName, |
|
|
[NotNull] string templateName, |
|
|
[CanBeNull] object model = null, |
|
|
object? model = null, |
|
|
[CanBeNull] string cultureName = null, |
|
|
string? cultureName = null, |
|
|
[CanBeNull] Dictionary<string, object> globalContext = null) |
|
|
Dictionary<string, object>? globalContext = null) |
|
|
{ |
|
|
{ |
|
|
Check.NotNullOrWhiteSpace(templateName, nameof(templateName)); |
|
|
Check.NotNullOrWhiteSpace(templateName, nameof(templateName)); |
|
|
|
|
|
|
|
|
@ -70,9 +70,9 @@ public class RazorTemplateRenderingEngine : TemplateRenderingEngineBase, ITransi |
|
|
|
|
|
|
|
|
protected virtual async Task<string> RenderInternalAsync( |
|
|
protected virtual async Task<string> RenderInternalAsync( |
|
|
string templateName, |
|
|
string templateName, |
|
|
string body, |
|
|
string? body, |
|
|
Dictionary<string, object> globalContext, |
|
|
Dictionary<string, object> globalContext, |
|
|
object model = null) |
|
|
object? model = null) |
|
|
{ |
|
|
{ |
|
|
var templateDefinition = await TemplateDefinitionManager.GetAsync(templateName); |
|
|
var templateDefinition = await TemplateDefinitionManager.GetAsync(templateName); |
|
|
|
|
|
|
|
|
@ -97,9 +97,9 @@ public class RazorTemplateRenderingEngine : TemplateRenderingEngineBase, ITransi |
|
|
|
|
|
|
|
|
protected virtual async Task<string> RenderSingleTemplateAsync( |
|
|
protected virtual async Task<string> RenderSingleTemplateAsync( |
|
|
TemplateDefinition templateDefinition, |
|
|
TemplateDefinition templateDefinition, |
|
|
string body, |
|
|
string? body, |
|
|
Dictionary<string, object> globalContext, |
|
|
Dictionary<string, object> globalContext, |
|
|
object model = null) |
|
|
object? model = null) |
|
|
{ |
|
|
{ |
|
|
return await RenderTemplateContentWithRazorAsync( |
|
|
return await RenderTemplateContentWithRazorAsync( |
|
|
templateDefinition, |
|
|
templateDefinition, |
|
|
@ -111,13 +111,13 @@ public class RazorTemplateRenderingEngine : TemplateRenderingEngineBase, ITransi |
|
|
|
|
|
|
|
|
protected virtual async Task<string> RenderTemplateContentWithRazorAsync( |
|
|
protected virtual async Task<string> RenderTemplateContentWithRazorAsync( |
|
|
TemplateDefinition templateDefinition, |
|
|
TemplateDefinition templateDefinition, |
|
|
string body, |
|
|
string? body, |
|
|
Dictionary<string, object> globalContext, |
|
|
Dictionary<string, object> globalContext, |
|
|
object model = null) |
|
|
object? model = null) |
|
|
{ |
|
|
{ |
|
|
var assembly = await AbpCompiledViewProvider.GetAssemblyAsync(templateDefinition); |
|
|
var assembly = await AbpCompiledViewProvider.GetAssemblyAsync(templateDefinition); |
|
|
var templateType = assembly.GetType(AbpRazorTemplateConsts.TypeName); |
|
|
var templateType = assembly.GetType(AbpRazorTemplateConsts.TypeName)!; |
|
|
var template = (IRazorTemplatePage)Activator.CreateInstance(templateType); |
|
|
var template = (IRazorTemplatePage)Activator.CreateInstance(templateType)!; |
|
|
|
|
|
|
|
|
using (var scope = ServiceScopeFactory.CreateScope()) |
|
|
using (var scope = ServiceScopeFactory.CreateScope()) |
|
|
{ |
|
|
{ |
|
|
@ -147,11 +147,11 @@ public class RazorTemplateRenderingEngine : TemplateRenderingEngineBase, ITransi |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void SetModel<TModel>(IRazorTemplatePage razorTemplatePage, object model = null) |
|
|
private void SetModel<TModel>(IRazorTemplatePage razorTemplatePage, object? model = null) |
|
|
{ |
|
|
{ |
|
|
if (razorTemplatePage is IRazorTemplatePage<TModel> razorTemplatePageWithModel) |
|
|
if (razorTemplatePage is IRazorTemplatePage<TModel> razorTemplatePageWithModel) |
|
|
{ |
|
|
{ |
|
|
razorTemplatePageWithModel.Model = (TModel)model; |
|
|
razorTemplatePageWithModel.Model = (TModel?)model; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|