|
|
|
@ -2,6 +2,7 @@ |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.AspNetCore.Mvc.RazorPages; |
|
|
|
using Microsoft.AspNetCore.Mvc.ViewFeatures; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.Extensions.Localization; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.Extensions.Logging.Abstractions; |
|
|
|
@ -21,19 +22,43 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.RazorPages |
|
|
|
{ |
|
|
|
public abstract class AbpPageModel : PageModel |
|
|
|
{ |
|
|
|
public IClock Clock { get; set; } |
|
|
|
public IServiceProvider ServiceProvider { get; set; } |
|
|
|
protected readonly object ServiceProviderLock = new object(); |
|
|
|
protected TService LazyGetRequiredService<TService>(ref TService reference) |
|
|
|
{ |
|
|
|
if (reference == null) |
|
|
|
{ |
|
|
|
lock (ServiceProviderLock) |
|
|
|
{ |
|
|
|
if (reference == null) |
|
|
|
{ |
|
|
|
reference = ServiceProvider.GetRequiredService<TService>(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return reference; |
|
|
|
} |
|
|
|
|
|
|
|
public IClock Clock => LazyGetRequiredService(ref _clock); |
|
|
|
private IClock _clock; |
|
|
|
|
|
|
|
public AlertList Alerts => AlertManager.Alerts; |
|
|
|
|
|
|
|
public IUnitOfWorkManager UnitOfWorkManager { get; set; } |
|
|
|
public IUnitOfWorkManager UnitOfWorkManager => LazyGetRequiredService(ref _unitOfWorkManager); |
|
|
|
private IUnitOfWorkManager _unitOfWorkManager; |
|
|
|
|
|
|
|
public IObjectMapper ObjectMapper { get; set; } |
|
|
|
public IObjectMapper ObjectMapper => LazyGetRequiredService(ref _objectMapper); |
|
|
|
private IObjectMapper _objectMapper; |
|
|
|
|
|
|
|
public IGuidGenerator GuidGenerator { get; set; } |
|
|
|
public IGuidGenerator GuidGenerator => LazyGetRequiredService(ref _guidGenerator); |
|
|
|
private IGuidGenerator _guidGenerator; |
|
|
|
|
|
|
|
public ILoggerFactory LoggerFactory { get; set; } |
|
|
|
public ILoggerFactory LoggerFactory => LazyGetRequiredService(ref _loggerFactory); |
|
|
|
private ILoggerFactory _loggerFactory; |
|
|
|
|
|
|
|
public IStringLocalizerFactory StringLocalizerFactory { get; set; } |
|
|
|
public IStringLocalizerFactory StringLocalizerFactory => LazyGetRequiredService(ref _stringLocalizerFactory); |
|
|
|
private IStringLocalizerFactory _stringLocalizerFactory; |
|
|
|
|
|
|
|
public IStringLocalizer L |
|
|
|
{ |
|
|
|
@ -56,17 +81,23 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.RazorPages |
|
|
|
|
|
|
|
protected Type LocalizationResourceType { get; set; } |
|
|
|
|
|
|
|
public ICurrentUser CurrentUser { get; set; } |
|
|
|
public ICurrentUser CurrentUser => LazyGetRequiredService(ref _currentUser); |
|
|
|
private ICurrentUser _currentUser; |
|
|
|
|
|
|
|
public ICurrentTenant CurrentTenant { get; set; } |
|
|
|
public ICurrentTenant CurrentTenant => LazyGetRequiredService(ref _currentTenant); |
|
|
|
private ICurrentTenant _currentTenant; |
|
|
|
|
|
|
|
public ISettingProvider SettingProvider { get; set; } |
|
|
|
public ISettingProvider SettingProvider => LazyGetRequiredService(ref _settingProvider); |
|
|
|
private ISettingProvider _settingProvider; |
|
|
|
|
|
|
|
public IModelStateValidator ModelValidator { get; set; } |
|
|
|
public IModelStateValidator ModelValidator => LazyGetRequiredService(ref _modelValidator); |
|
|
|
private IModelStateValidator _modelValidator; |
|
|
|
|
|
|
|
public IAuthorizationService AuthorizationService { get; set; } |
|
|
|
public IAuthorizationService AuthorizationService => LazyGetRequiredService(ref _authorizationService); |
|
|
|
private IAuthorizationService _authorizationService; |
|
|
|
|
|
|
|
public IAlertManager AlertManager { get; set; } |
|
|
|
public IAlertManager AlertManager => LazyGetRequiredService(ref _alertManager); |
|
|
|
private IAlertManager _alertManager; |
|
|
|
|
|
|
|
protected IUnitOfWork CurrentUnitOfWork => UnitOfWorkManager?.Current; |
|
|
|
|
|
|
|
|