using XFEExtension.NetCore.WinUIHelper.Interface.Services;
using XFEExtension.NetCore.WinUIHelper.Utilities.Helpers;
namespace XFEExtension.NetCore.WinUIHelper.Implements.Services;
///
/// Provides functionality to manage the visibility of page elements based on permission levels within the application.
///
/// Use this service to initialize the current page context and update the visibility of its child
/// elements according to the specified permission level. This service is typically used to control access to UI
/// components depending on user roles or permissions.
public class PermissionVisibilityService : GlobalServiceBase, IPermissionVisibilityService
{
private Page? currentPage;
///
public Page? CurrentPage => currentPage;
///
public void Initialize(Page page)
{
currentPage = page;
}
///
public void Refresh(int permissionLevel) => PermissionHelper.SetChildVisibility(currentPage!, permissionLevel);
}