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