Ejemplo n.º 1
0
        /// <summary>
        /// Inserts a <see cref="AccessRuleItem" /> to the specified <paramref name="item" />.
        /// </summary>
        /// <param name="objectType">The type of the shared object to be found.</param>
        /// <param name="objectId">The primary key of the shared object to be found.</param>
        /// <param name="rule">The ACEs (Access Control Entries) to set.</param>
        /// <param name="cancellationToken">A token to observe while waiting for the task to complete.</param>
        /// <returns>
        /// A task that represents the asynchronous operation.
        /// </returns>
        /// <exception cref="System.ArgumentNullException"></exception>
        public virtual async Task <ValidationResult> AddAccessRuleAsync(AccessObjectType objectType, int objectId, AccessRuleItem rule, CancellationToken cancellationToken)
        {
            ThrowIfDisposed();
            if (rule == null)
            {
                throw new ArgumentNullException(nameof(rule));
            }

            var validationResult = await ValidateAccessRuleAsync(objectType, objectId, rule, cancellationToken);

            if (!validationResult.Succeeded)
            {
                return(validationResult);
            }
            return(await Store.AddAccessRuleAsync(objectType, objectId, rule, cancellationToken));
        }