| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using Abp.Application.Features;
- using Abp.Authorization;
- using Abp.Runtime.Session;
- namespace Abp.Application.Services
- {
- /// <summary>
- /// This class can be used as a base class for application services.
- /// </summary>
- public abstract class ApplicationService : AbpServiceBase, IApplicationService, IAvoidDuplicateCrossCuttingConcerns
- {
- public static string[] CommonPostfixes = { "AppService", "ApplicationService" };
- /// <summary>
- /// Gets current session information.
- /// </summary>
- public IAbpSession AbpSession { get; set; }
-
- /// <summary>
- /// Reference to the permission manager.
- /// </summary>
- public IPermissionManager PermissionManager { protected get; set; }
- /// <summary>
- /// Reference to the permission checker.
- /// </summary>
- public IPermissionChecker PermissionChecker { protected get; set; }
- /// <summary>
- /// Reference to the feature manager.
- /// </summary>
- public IFeatureManager FeatureManager { protected get; set; }
- /// <summary>
- /// Reference to the feature checker.
- /// </summary>
- public IFeatureChecker FeatureChecker { protected get; set; }
- /// <summary>
- /// Gets the applied cross cutting concerns.
- /// </summary>
- public List<string> AppliedCrossCuttingConcerns { get; } = new List<string>();
- /// <summary>
- /// Constructor.
- /// </summary>
- protected ApplicationService()
- {
- AbpSession = NullAbpSession.Instance;
- PermissionChecker = NullPermissionChecker.Instance;
- }
- /// <summary>
- /// Checks if current user is granted for a permission.
- /// </summary>
- /// <param name="permissionName">Name of the permission</param>
- protected virtual Task<bool> IsGrantedAsync(string permissionName)
- {
- return PermissionChecker.IsGrantedAsync(permissionName);
- }
- /// <summary>
- /// Checks if current user is granted for a permission.
- /// </summary>
- /// <param name="permissionName">Name of the permission</param>
- protected virtual bool IsGranted(string permissionName)
- {
- return PermissionChecker.IsGranted(permissionName);
- }
- /// <summary>
- /// Checks if given feature is enabled for current tenant.
- /// </summary>
- /// <param name="featureName">Name of the feature</param>
- /// <returns></returns>
- protected virtual Task<bool> IsEnabledAsync(string featureName)
- {
- return FeatureChecker.IsEnabledAsync(featureName);
- }
- /// <summary>
- /// Checks if given feature is enabled for current tenant.
- /// </summary>
- /// <param name="featureName">Name of the feature</param>
- /// <returns></returns>
- protected virtual bool IsEnabled(string featureName)
- {
- return FeatureChecker.IsEnabled(featureName);
- }
- }
- }
|