Browse Source
Disable reader cache in the development environment.
Resolve #20589
pull/20638/head
maliming
1 year ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
3 changed files with
12 additions and
3 deletions
-
framework/src/Volo.Abp.TextTemplating.Core/Volo/Abp/TextTemplating/VirtualFiles/LocalizedTemplateContentReaderFactory.cs
-
framework/test/Volo.Abp.TextTemplating.Razor.Tests/Volo/Abp/TextTemplating/Razor/RazorLocalizedTemplateContentReaderFactory_Tests.cs
-
framework/test/Volo.Abp.TextTemplating.Scriban.Tests/Volo/Abp/TextTemplating/Scriban/ScribanLocalizedTemplateContentReaderFactory_Tests.cs
|
|
|
@ -13,16 +13,23 @@ public class LocalizedTemplateContentReaderFactory : ILocalizedTemplateContentRe |
|
|
|
protected IVirtualFileProvider VirtualFileProvider { get; } |
|
|
|
protected ConcurrentDictionary<string, ILocalizedTemplateContentReader> ReaderCache { get; } |
|
|
|
protected SemaphoreSlim SyncObj; |
|
|
|
protected IAbpHostEnvironment AbpHostEnvironment { get; } |
|
|
|
|
|
|
|
public LocalizedTemplateContentReaderFactory(IVirtualFileProvider virtualFileProvider) |
|
|
|
public LocalizedTemplateContentReaderFactory(IVirtualFileProvider virtualFileProvider, IAbpHostEnvironment abpHostEnvironment) |
|
|
|
{ |
|
|
|
VirtualFileProvider = virtualFileProvider; |
|
|
|
AbpHostEnvironment = abpHostEnvironment; |
|
|
|
ReaderCache = new ConcurrentDictionary<string, ILocalizedTemplateContentReader>(); |
|
|
|
SyncObj = new SemaphoreSlim(1, 1); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<ILocalizedTemplateContentReader> CreateAsync(TemplateDefinition templateDefinition) |
|
|
|
{ |
|
|
|
if (AbpHostEnvironment.IsDevelopment()) |
|
|
|
{ |
|
|
|
return await CreateInternalAsync(templateDefinition); |
|
|
|
} |
|
|
|
|
|
|
|
if (ReaderCache.TryGetValue(templateDefinition.Name, out var reader)) |
|
|
|
{ |
|
|
|
return reader; |
|
|
|
|
|
|
|
@ -12,7 +12,8 @@ public class RazorLocalizedTemplateContentReaderFactory_Tests : LocalizedTemplat |
|
|
|
LocalizedTemplateContentReaderFactory = new LocalizedTemplateContentReaderFactory( |
|
|
|
new PhysicalFileVirtualFileProvider( |
|
|
|
new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), |
|
|
|
"Volo", "Abp", "TextTemplating", "Razor")))); |
|
|
|
"Volo", "Abp", "TextTemplating", "Razor"))), |
|
|
|
GetRequiredService<IAbpHostEnvironment>()); |
|
|
|
|
|
|
|
WelcomeEmailEnglishContent = "@inherits Volo.Abp.TextTemplating.Razor.RazorTemplatePageBase<Volo.Abp.TextTemplating.Razor.RazorTemplateRendererProvider_Tests.WelcomeEmailModel>" + |
|
|
|
Environment.NewLine + |
|
|
|
|
|
|
|
@ -11,7 +11,8 @@ public class ScribanLocalizedTemplateContentReaderFactory_Tests : LocalizedTempl |
|
|
|
LocalizedTemplateContentReaderFactory = new LocalizedTemplateContentReaderFactory( |
|
|
|
new PhysicalFileVirtualFileProvider( |
|
|
|
new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), |
|
|
|
"Volo", "Abp", "TextTemplating", "Scriban")))); |
|
|
|
"Volo", "Abp", "TextTemplating", "Scriban"))), |
|
|
|
GetRequiredService<IAbpHostEnvironment>()); |
|
|
|
|
|
|
|
WelcomeEmailEnglishContent = "Welcome {{model.name}} to the abp.io!"; |
|
|
|
WelcomeEmailTurkishContent = "Merhaba {{model.name}}, abp.io'ya hoşgeldiniz!"; |
|
|
|
|