Browse Source

AbpComponentBase should use non-scoped services for message and notification

pull/6061/head
Halil İbrahim Kalkan 6 years ago
parent
commit
0f9eb3add4
  1. 19
      framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs

19
framework/src/Volo.Abp.AspNetCore.Components/Volo/Abp/AspNetCore/Components/AbpComponentBase.cs

@ -54,10 +54,10 @@ namespace Volo.Abp.AspNetCore.Components
protected ICurrentUser CurrentUser => LazyGetRequiredService(ref _currentUser);
private ICurrentUser _currentUser;
protected IUiMessageService Message => LazyGetRequiredService(ref _message);
protected IUiMessageService Message => LazyGetNonScopedRequiredService(ref _message);
private IUiMessageService _message;
protected IUiNotificationService Notify => LazyGetRequiredService(ref _notify);
protected IUiNotificationService Notify => LazyGetNonScopedRequiredService(ref _notify);
private IUiNotificationService _notify;
protected IObjectMapper ObjectMapper
@ -97,6 +97,21 @@ namespace Volo.Abp.AspNetCore.Components
return reference;
}
protected TService LazyGetNonScopedRequiredService<TService>(ref TService reference) => LazyGetNonScopedRequiredService(typeof(TService), ref reference);
protected TRef LazyGetNonScopedRequiredService<TRef>(Type serviceType, ref TRef reference)
{
if (reference == null)
{
reference = (TRef)NonScopedServices.GetRequiredService(serviceType);
}
return reference;
}
[Inject]
protected IServiceProvider NonScopedServices { get; set; }
protected virtual IStringLocalizer CreateLocalizer()
{
if (LocalizationResource != null)

Loading…
Cancel
Save