/// <summary>
        /// Gets if the specified command or its module is locked.
        /// </summary>
        /// <param name="locking">The locking service to work with.</param>
        /// <param name="context">The command context to look for.</param>
        /// <param name="command">The command to check.</param>
        /// <returns>True if the command or its module is locked.</returns>
        public static async Task <bool> IsLockedAsync(this IContextingService locking, ICommandContext context, CommandDetails command)
        {
            IDbLockableContext lockContext = await locking.FindDbLockableContextAsync(context).ConfigureAwait(false);

            if (lockContext == null)
            {
                return(command.IsLockedByDefault || command.Module.IsLockedByDefault);
            }
            return(command.IsLocked(lockContext));
        }
Exemple #2
0
 /// <summary>
 /// Formats a command to show the locked symbol when it or its module is locked.
 /// </summary>
 private string FormatLocked(IDbLockableContext lockContext, CommandDetails command)
 {
     return(command.IsLocked(lockContext) ? Locked : string.Empty);
 }