/// <summary>
 ///     check if the supplied permissions are available
 /// </summary>
 /// <param name="neededPermissions"></param>
 /// <param name="permissionOperation">PermissionOperations</param>
 /// <returns>true if the permissions are available</returns>
 private bool HasPermissions(IEnumerable <string> neededPermissions, PermissionOperations permissionOperation = PermissionOperations.Or)
 {
     // Null permission is aways there
     if (neededPermissions == null)
     {
         return(true);
     }
     return(_authenticationProvider?.Value.HasPermissions(neededPermissions, permissionOperation) ?? false);
 }
예제 #2
0
        /// <inheritdoc />
        public bool HasPermissions(IEnumerable <string> neededPermissions, PermissionOperations permissionOperation = PermissionOperations.Or)
        {
            // Argument check
            if (neededPermissions == null)
            {
                throw new ArgumentNullException(nameof(neededPermissions));
            }

            // Create a clean list of permissions needed
            var permissionsToCompare = neededPermissions.Where(s => !string.IsNullOrWhiteSpace(s)).Select(permission => permission.Trim().ToLowerInvariant()).ToList();

            if (permissionOperation == PermissionOperations.Or)
            {
                return(permissionsToCompare.Any(permission => _permissions.Contains(permission)));
            }
            return(permissionsToCompare.All(permission => _permissions.Contains(permission)));
        }
 /// <summary>
 ///     Sets the permissions Operation of the UIElement to the DependencyProperty specified in
 ///     PermissionsOperationProperty.
 /// </summary>
 /// <param name="uiElement">UIElement</param>
 /// <param name="permissionOperations">PermissionOperations</param>
 public static void SetPermissionsOperations(UIElement uiElement, PermissionOperations permissionOperations)
 {
     uiElement.SetValue(PermissionsOperationProperty, permissionOperations);
 }